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
-
C0D4669023yJavascript devs who dont read the docs.
Well, any dev that doesn't read the docs really. -
Having stringy sort by default is actually better because converting to integer sort is as simple as arr.sort((a, b) => a - b) but if it was integer sort by default, you would have to do
arr.sort((a, b) => {
if (a < b) return -1
if (a > b) return 1
return 0
});
to convert it to stringy sort. -
How about the correct sort depending on the array containing numbers or strings? Like in all normal languages?
-
Meh, just don't take random sorting algorithm for granted. It will save the embarrassment.
-
@Lensflare If you sort an array that only contains numbers it'll sort correctly, it only sorts in a "stringy" way if all elements except one are strings. In all other cases the behavior is undefined because the standard dictates that the relation function must be transitive and ">" on a mixed set of numbers and strings isn't transitive.
Related Rants
Javascript Developers😂
joke/meme
js
framework
developer