Numerically Sort Arrays
HTML
By default the sort method sorts elements alphabetically. To sort numerically just add a new method which handles numeric sorts (sortNumber, shown below)
JavaScript
function sortNumber(a,b) {
return a - b;
}
var numArray = [140000, 104, 99];
//numArray.sort(function (a, b) { return a - b; });
//numArray.sort(function (a, b) { return b - a; });
numArray.sort(function (a, b) { return 0; });
alert(numArray);