c/programminghumor · by 2e8a9d6bb6935a54@lemmy.world · 3yJavascript sort is the best sort 84 points · 9 comments · view on lemmy.world
9 Comments
Seigest@lemmy.ca · 24 pts · 3y
Didn't belive it. tried it. died a little more inside.
poopsmith@lemmy.world · 18 pts · 3y
From MDN:
So, if you're trying to sort numbers,
[6, -2, 2, -7].sort((a, b) => a - b)Solumbran@lemmy.world · 4 pts · 2y
That might be explainable, but doesn't make it logical or acceptable.
Blamemeta@lemmy.world · 17 pts · 3y
Its converting numbers to strings.
EatMyDick@lemmy.world · -3 pts · 3y
Yes. Asute observation captain.
_sideffect@lemmy.world · 15 pts · 3y
Imagine going for a JavaScript coding interview and failing because of this 😂
skates@sh.itjust.works · 4 pts · 3y
That's a good point lol, I haven't done a js interview yet but it'd probably be kinda rough trying to remember random shit like this.
EatMyDick@lemmy.world · -3 pts · 3y
Meh, it's a day 2 thing to understand how shitty JS deals with numbers. Good devs will cover their asses by default.
sulungskwa@lemmy.world · 9 pts · 3y
Blessed are those that use
Array.sortwithout passing it arguments