js sort function with numbers code example
Example 1: javascript sort numbers
var numArray = [140000, 104, 99];
numArray.sort(function(a, b) {
return a - b;
});
// Array(3) [ 99, 104, 140000 ]
Example 2: sort numbers in array javascript
function sortNumber(a, b) {
return a - b;
}
Arr.sort(sortNumber);