![]()
Hi, in one of my scenarios, I need to sort an array containing always the same structure:
filename6.jpg, filename8.jpg, filename5.jpg, filename10.jpg
For now, I used this and it worked for all items below 10:
But when there is a 10 or above, it doesn’t work and this is what happens:
filename10.jpg, filename5.jpg, filename6.jpg,filename8.jpg
I understand that this is how javascript works (alphabetical and not numerical sorting) but is there a way to force numerical sorting?
If the filename structure is always the same, a potential workaround could be to
- extract the number of the file as the “number” item data type
- add it to a new array of items you need to use further in the flow
- sort the array with the “sort” function as the “number” item data type would be used instead of a “string”
Extracting the number of the file
Adding the number of the file to a new array
Sorting the array
Helpful Links:
Functions in Help Center