JavaScript always know my truest of desires

kuneho@lemmy.world to Programmer Humor@programming.dev – 428 points –

38

You are viewing a single comment

I couldn't believe it, tried it out, what the actual heck? I mean I get all these weird string vs number comparison but sorting actual numbers and this comes out? What kind of drugs were the designers of javascript (or at least this function) on... Who thought it was a good idea to sort numbers lexicographically??

Iirc Array.sort requires you to pass a function in, or it casts into strings and sort them.

1 more...