Follow

@moffintosh oh dear lord no matter how many JS horrors I see, it always manages to up the stakes

@moffintosh so apparently the default `.sort()` compares UTF-16 code units. It will not only sort -2 before -7, it will also sort 10 before 9. Truly cursed stuff.

@Amikke @moffintosh well yeah, it sorts numbers as text because that's a good idea and using typed languages is way too complicated

@uberrice @moffintosh better yet, it then converts them back to numbers so that it's not immediately obvious string-comparing shenanigans happened. Very JS moment.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.