Answers for "js sort number array"

5

javascript sort array smallest to largest

var numArray = [140000, 104, 99];
numArray.sort(function(a, b) {
  return a - b;
});

console.log(numArray);
Posted by: Guest on July-07-2020
3

sorting of arraray's number element in javascript

let numbers = [0, 1, 2, 3, 10, 20, 30];
numbers.sort((a, b) => a - b);

console.log(numbers);
Posted by: Guest on April-17-2020
1

sort numbers in array javascript

function sortNumber(a, b) {
  return a - b;
}
Arr.sort(sortNumber);
Posted by: Guest on March-01-2020

Browse Popular Code Answers by Language