Compare primitives the right way (using
This module does the right thing with numbers and ascii strings.
String.prototype.localeCompare is recommended for strings,
but that can have nasty side effects on some machines, eg.
Compare the above in stock node (which doesn't come with
a browser of your choice (which most likely has
var compare =1 2 10 // [1, 10, 2]1 2 10 // [1, 2, 10]// Below is sorted correctly according to Hungarian, but runtimes without Intl// support will reorder them'cu' 'cs''cu' 'cs' // This will always sort the same
Array.prototype.sort(cmp) function signature. If
a > b return
a < b return
-1, otherwise return
hughsk for the npm name!
npm install compare