Answers for "sort method on array"

-1

sort() function example JavaScript

function ascendingOrder(arr) {
  return arr.sort(function(a, b) {
    return a - b;
  });
}
ascendingOrder([1, 5, 2, 3, 4]);
Posted by: Guest on April-24-2021

Browse Popular Code Answers by Language