You must log in or register to comment.
This is due to the default sorter in JavaScript sorting by the string value. The reason for that is that this won’t create errors at runtime. Since JavaScript does not have types, this is the safest way of sorting.
This works:
const unsorted = [1, 100000, 21, 30, 4] const sorted = unsorted.sort((a, b) => a - b)
Honestly this being javascript I expected the answer to be
[4, 1, 100000, 30, 21]
(sorted alphabetically by name)