3 ms·
No, it makes sense to sort strings when you get handed strings, and sort numbers when handed numbers. Period. Default behavior is now exactly as expected by 100
by dsl 13y ago
No, it makes sense to sort strings when you get handed strings, and sort numbers when handed numbers. Period. Default behavior is now exactly as expected by 100% of developers.
Your creativity as a language designer should only come in to play when dealing with sets of mixed type.
- Yaggo 13y agoSo how should [1, "a", 2, 3] be sorted by default?
- integraton 13y agoBoth Python and Erlang would return [1,2,3,"a"], Ruby and Clojure won't allow the comparison. Either of these approaches makes more sense than JavaScript's.
- bpicolo 13y agoJavascript returns [1,2,3,a]. What's the problem.
- integraton 13y ago> [1,2,"10",3].sort() [ 1, '10', 2, 3 ] That's the problem.