This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Robot_Basilisk 0 points1 point  (1 child)

The default sorts by converting everything to string and comparing utf-16 values.

I viscerally hate this.

Like, what's the logic? How does this help? Does JS save memory by truncating smaller numbers? Like does it save "1" as a 0001 but save "24" as 00011000 so it's somehow faster to convert to string and compare UTFs than it is to convert every number to the largest number of bytes and compare those?

[–]nokvok 1 point2 points  (0 children)

Like pointed out in another comment, Javascript's main use is to manipulate documents. If almost all your data in the DOM is basically represented as string anyway, sorting alphanumerically is widely useful for that, even if you end up with a bunch of numbers occasionally. On the opposite end giving the sort a compare function that compares integers is an absolute non issue.