n8n
n8n copied to clipboard
Simple Sort doesn't work for numbers
Found a bug? Please fill out the sections below. 👍
Issue Summary
Using the ItemsList node, the Operation "Sort" and choosing the Type "Simple", and giving it a number field, it's not properly sorted.
Steps to Reproduce
- Provide any input to the ItemsList node with numbers mixed randomly (with different numbers of digits);
- Check output;
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead? I expect it to sort the numbers Ascending or Descending as the UI suggests that it does.
Technical details
- Running version: 0.186.1
Here's a screenshot:
Hey @Chinoman10,
I have just been looking at this one and I can see the issue you are having and was able to reproduce it but I wouldn't classify it as a bug, Looking at the data you have in the node the amounts are strings not numbers so the data is being sorted as a string. If you were to take the same values and run them through a set node or code first to convert them to numbers it works as expected.
This of course is not great but hopefully shows a bit of insight as to what is happening, What I have done is added this to our internal product ideas list as it would be a great feature to automatically convert the data type or at least provide an option so you can decide if we convert it or not.
For now I am going to mark this one as closed as while it is annoying for the reasons above it isn't really a bug, If you have any questions let me know.