this post was submitted on 07 Jul 2023
433 points (98.7% liked)

Programmer Humor

19876 readers
182 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 7 points 2 years ago (3 children)

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??

[–] [email protected] 5 points 2 years ago (1 children)

Probably meth or cocaine, considering js was written by a single person in 10 days

[–] [email protected] 1 points 2 years ago

That way they get to reuse the code for sorting strings!

[–] [email protected] 1 points 2 years ago

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