Answers for "how to make an array in ascending order in javascript"

25

ascending val in array using js

numArray.sort((a, b) => a - b); // For ascending sort
numArray.sort((a, b) => b - a); // For descending sort
Posted by: Guest on May-08-2021
-1

javascript sort by id

elems.sort((a, b) => a.id - b.id);
Posted by: Guest on June-17-2020
1

javascript sort array in ascending order

//sorts arrays of numbers
function myFunction() {
  points.sort(function(a, b){return a-b});
  document.getElementById("demo").innerHTML = points;
}
Posted by: Guest on March-25-2020

Code answers related to "how to make an array in ascending order in javascript"

Browse Popular Code Answers by Language