I’m not able to abstract away what I’m doing wrong here so I’m hoping for some help.
I’m using HTML extract > Set and then trying to sort the output > Sort according to JavaScript Code Snippets | Docs, but I’m failing.
First, I get [HTML extract]
which I then [Set] into something useful as they need to be properly assigned to each other
Now, I see that at this stage I don’t have any “key” element to use the sort instruction on [neither on the number as a string or as a number, the HTML extract imports it as a string].
Just for completeness, here are the instructions for sorting from the documentation:
String sorting:
const sortedArr = items.sort((a, b) => {
let a_name = a.json.name.toLowerCase(),
b_name = b.json.name.toLowerCase();
if (a_name < b_name) {
return -1;
}
if (a_name > b_name) {
return 1;
}
return 0;
});
return json:sortedArr;
Number sorting
const sortedArr = items.sort((a, b) => {
return a.json.id - b.json.id;
})
return sortedArr;
Thanks a lot, I’m stuck so I’m happy about any guidance.