setDistinct changes order
Nothing in the documentation for setDistinct implies anything about sorting the array/matrix, yet:
math.setDistinct([3, 1, 2]); // [1, 2, 3]
math.setDistinct(['h', 'e', 'l', 'l', 'o']); // ['e', 'h', 'l', 'o']
Expected
math.setDistinct([3, 1, 2]); // [3, 1, 2]
math.setDistinct(['h', 'e', 'l', 'l', 'o']); // ['h', 'e', 'l', 'o']
Docs: setDistinct
Code: .sort(compareNatural)
Thanks. I've added a sentence to the description to explain that the results will be sorted, see 4bbe862.
However, I would prefer the result not to be sorted. It shouldn't be hard to change the code to leave the original order as-is. It will be a breaking change so I'll schedule it for the first next major version.
Who can implement this change? Help would be welcome.
Hi Josdejong, fixed and created a pull request - https://github.com/josdejong/mathjs/pull/3603. Also added new test cases. Can you please look into it.