This is from a node cli session:
> var a = 'foo12';
undefined
> var b = 'foo3';
undefined
> var s = [a , b];
undefined
> s.sort(function(a, b) {
... return a.localeCompare(b, 'en', { numeric: true });
... });
[ 'foo12', 'foo3' ]
This is from the Chrome console:
var a = 'foo12';
undefined
var b = 'foo3';
undefined
var s = [a,b]
undefined
s.sort(function(a,b) {return a.localeCompare(b, 'en', {numeric:true});})
["foo3", "foo12"]
I.e., the numeric: true
option for natural sorting seems to be a no-op in my setup for node.
Is there a way to get node to behave better in this situation, or an explanation as to why it does not?