By default, Javascript sorts an array in a lexicographical way.
To sort numeric array, provide a comparison function. Use the code below:
myArray.sort(function(a,b) { return a – b; } );
Bruce Ng's software development blog
An archive of solutions of programming problems I have faced in my career
To sort numeric array, provide a comparison function. Use the code below:
myArray.sort(function(a,b) { return a – b; } );