About 314,000 results
Open links in new tab
  1. Array.prototype.sort () - JavaScript | MDN

    Apr 3, 2025 · The sort () method of Array instances sorts the elements of an array in place and returns the reference to the same array, now sorted. The default sort order is ascending, built …

  2. JavaScript Array Sort - W3Schools

    By combining sort() and reverse(), you can sort an array in descending order: ES2023 added the toSorted() method as a safe way to sort an array without altering the original array.

  3. JavaScript Array sort: Sorting an Array More Effectively

    This tutorial shows you how to use the JavaScript array sort method to sort arrays of numbers, strings, and objects.

  4. JavaScript Array sort() Method - GeeksforGeeks

    Nov 12, 2024 · The JS array.sort () method rearranges the array elements alphabetically and returns a sorted array. It does not create a new array but updates the original array.

  5. How can you sort an array without mutating the original array?

    With the introduction of the new .toSorted method in JavaScript, there's now a straightforward way to get a sorted copy of the array without modifying the original array: const sorted = …

  6. JavaScript Sort () – How to Use the Sort Function in JS

    May 16, 2023 · What is the sort() Function? The sort() function allows you to sort an array object by either the default sorting order, or by a custom sorting function. By default, it sorts the …

  7. JavaScript Array sort () - Programiz

    Here, arr is an array. The sort() method takes in: compareFunction (optional) - It is used to define a custom sort order. Returns the array after sorting the elements of the array in place …

  8. How to sort array in JavaScript? [SOLVED] - GoLinuxCloud

    Dec 20, 2022 · In this article, we'll take a look at some of the different ways you can sort an array in JavaScript. One of the most basic ways to sort an array is using the Array.sort() method. …

  9. JavaScript Array sort () Method - CodeToFun

    Nov 20, 2024 · The sort() method is used to arrange the elements of an array either in ascending or descending order. By default, it sorts elements as strings, which may lead to unexpected …

  10. Sorting an Array in JavaScript - Mastering JS

    May 30, 2019 · To sort an array of numbers in forward order, you should use (a, b) => a - b as your compareFunction(). To sort an array of numbers in reverse order, you should use (a, b) …

  11. Some results have been removed
Refresh