n8n icon indicating copy to clipboard operation
n8n copied to clipboard

Simple Sort doesn't work for numbers

Open Chinoman10 opened this issue 2 years ago • 1 comments

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

  1. Provide any input to the ItemsList node with numbers mixed randomly (with different numbers of digits);
  2. 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

Chinoman10 avatar Jul 20 '22 15:07 Chinoman10

Here's a screenshot: image

Chinoman10 avatar Jul 20 '22 15:07 Chinoman10

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.

Joffcom avatar Jan 18 '23 16:01 Joffcom