mathjs icon indicating copy to clipboard operation
mathjs copied to clipboard

setDistinct changes order

Open DavidMulder0 opened this issue 1 month ago • 2 comments

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)

DavidMulder0 avatar Nov 24 '25 07:11 DavidMulder0