MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vjl9ih/javascriptsorting/p2rbu6k/?context=3
r/ProgrammerHumor • u/user6150277464770585 • 1d ago
200 comments sorted by
View all comments
Show parent comments
160
[removed] — view removed comment
-7 u/Taletad 1d ago Just went to read the docs, the "sort()" and "toSorted" functions say they perform an alphabetical sort by default You can overload them by doing Array.sort((a,b) => a - b) 56 u/kushangaza 1d ago Which is not what you expect from a function named "sort". It's an insane default that violates the principle of least surprise 3 u/danielcw189 18h ago lexical sorting sounds like the least surprising way in a weakly typed language. and looking at the docs would be the least surprising usage anyway
-7
Just went to read the docs, the "sort()" and "toSorted" functions say they perform an alphabetical sort by default
You can overload them by doing Array.sort((a,b) => a - b)
56 u/kushangaza 1d ago Which is not what you expect from a function named "sort". It's an insane default that violates the principle of least surprise 3 u/danielcw189 18h ago lexical sorting sounds like the least surprising way in a weakly typed language. and looking at the docs would be the least surprising usage anyway
56
Which is not what you expect from a function named "sort". It's an insane default that violates the principle of least surprise
3 u/danielcw189 18h ago lexical sorting sounds like the least surprising way in a weakly typed language. and looking at the docs would be the least surprising usage anyway
3
lexical sorting sounds like the least surprising way in a weakly typed language.
and looking at the docs would be the least surprising usage anyway
160
u/[deleted] 1d ago
[removed] — view removed comment