I have some text blocks with footnotes but the order is sometimes not correct. The order depends on how the data comes from product.tech_datas. Sometimes it is correct, sometimes not. I need to sort it.
This is how I get the footnote.
const footnote = product.tech_datas.filter(techData => techData.datatype === 'DI');
if (isEmpty(footnote)) {
return;
}
The problem was that product.tech_datas can return footnotes in any order, e.g., ²⁾ first … and then ¹⁾. I probably need to write a sort function to sort ⁰¹²³…
I started with something but I am not sure how to continue...
const superscriptDigits = '⁰¹²³⁴⁵⁶⁷⁸⁹';
function superscriptToNumber(str: string): number {
const normal = str
.split('')
.join('');
return Number(normal);
}