Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@C0D4 agreed, I don't usually try and shit on OP but knowing that JS has alphabetical and numerical sort on the same method is pretty common knowledge.
It doesn't come close to our all powerful all knowing and encompassing php array sort 🥴 which took me a little over an entire month to understand that the thing would completely sort an array in place and yo boy was assigning the output of a sort to a variable.
I is genius -
C0D4623767d@AleCx04 don't we all do that at some point.
You feel like an total jackass when you work it out though 😅 -
@C0D4 I did but thankfully I was just starting with wev development and php. Now a days if something like that happens I would crawl into a ball in my office and my sraff wod have to force the door open to give me chocolate or something
-
@kiki Tounge in cheek. That's the usual response I get whenever I give ES6+ syntax as an example.
-
@AlmondSauce Why would you care about IE10- these days tho?
@10Dev you know you can use: @highlight yourArray.sort((a, b) => a-b) -
Hazarth19467dimo it doesn't matter that people that know JS know about this quirk, the point of this rant is that it's not a good design..
just think about it... the sort function takes your input, changes its type completely, and then sorts it on the data it made up...
I'd rather see it use named sorts like strSort, intSort or something... put it into it's respective type classes I don't care, but don't magically assume my input is something it's not when using a commonly named function like a generic "sort"... if your language doesn't have strong typing you shouldn't act like it has... you should design it in a way that makes it actually intuitive, or go the python way, and do type detection at function level...
this is bullshit and I dare you to defend this design...
pro tip: you can't
Related Rants
Can javascript please get a decent inbuilt sorting method?!
Like, wtf is this shit?
[1, 3, 2, 12, 24, 5, 17].sort() === [1, 12, 17, 2, 24, 3, 5]
I'm fucking tired of having to reinvent the wheel every fucking time
rant
js
wtf js
sorting