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

    May 23, 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 sorting with JavaScript's sort() is different from languages like C++ , Java and Python. It compares array elements alphabetically as strings rather than numbers. This causes …

  5. JavaScript Sort Array - How to Sort an Array Accurately

    Mar 14, 2023 · In this article, you will learn how to sort an array in JavaScript, some shortcomings associated with the sort() method, and how to get more accurate results. If you are in a rush, …

  6. JavaScript Array sort() - Programiz

    The sort() method compares all values of the array by passing two values at a time to the compareFunction. The two parameters a and b represent these two values respectively. The …

  7. JavaScript’s sort() method: From basics to custom sorting

    Mar 7, 2025 · There are two primary array sorting methods in JavaScript: the Array.prototype.sort method and the Array.prototype.toSorted method. Both of these techniques have built-in …

  8. JavaScript: Sorting Arrays

    May 7, 2025 · In this article, we’ve explored several ways to sort arrays in JavaScript, from sorting numbers and strings to sorting objects and dates. We learned how to use the built-in sort() …

  9. javascript - How to sort an array of integers? - Stack Overflow

    Jun 30, 2009 · By default, the sort method sorts elements alphabetically. To sort numerically just add a new method which handles numeric sorts (sortNumber, shown below) - return a - b; …

  10. JavaScript Array Sort – How to Use JS Sort Methods (With Code Examples)

    May 24, 2020 · In JavaScript, we can sort the elements of an array easily with a built-in method called the sort( ) function. However, data types (string, number, and so on) can differ from one …

  11. Some results have been removed
Refresh