r/programminghorror
•
u/Leonnee
•
Jun 12 '25
•
1
Javascript Javascript is filled with horror
2.4k
Upvotes
View all comments
Show parent comment
2
u/the_horse_gamer Jun 12 '25
that can introduce unexpected situations. your array suddenly sorting differently, depending on its contents. easier to reason about the behavior of the code when there aren't stuff like that.
if you're expecting all to be numbers, pass a comparison function. perhaps sortNumeric is ought to be added. but you'd need to define how to handle NaN.