Answers for "sort in js array"

25

JS array sort

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 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
-1

javascript sort

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();
Posted by: Guest on February-09-2020
-1

sort javascript

arr.sort()
arr.sort(fonctionComparaison)
Posted by: Guest on April-14-2021
-3

mdn array sort

arr.sort([compareFunction])
Posted by: Guest on November-05-2020

Browse Popular Code Answers by Language