Answers for "arrange array in ascending order js"

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

sort by ascending javascript

const months = ['March', 'Jan', 'Feb', 'Dec'];
months.sort();
console.log(months);
// expected output: Array ["Dec", "Feb", "Jan", "March"]
Posted by: Guest on October-28-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 "arrange array in ascending order js"

Browse Popular Code Answers by Language