About 1,830,000 results
Open links in new tab
  1. JavaScript Array sort() Method - W3Schools

    // Sort the numbers in descending order: points.sort(function(a, b){return b-a}); let highest = points[0];

  2. javascript - Using sort() to get numbers in descending order

    function descendingOrder(n) { let result = n .toString() // convert numbers to string .split('') // split each string char in to an array of chars .sort((a, b) => b - a) // sort that array descending .join('') …

  3. sorting an array in descending order in javascript without using …

    Aug 29, 2019 · function dscSort(array) { for (var i = 1; i < array.length; i++) { var tmp = array[i]; for (var j = i - 1; j >= 0 && (array[j] < array[i]); j--) { array[j + 1] = array[j]; } array[j + 1] = tmp; } …

  4. Sorting strings in descending order in Javascript (Most …

    Aug 27, 2018 · W3CSchools has this example: var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.sort(); fruits.reverse(); Is this the most efficient way to sort strings in …

  5. Array.prototype.sort() - JavaScript | MDN - MDN Web Docs

    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 …

  6. How to Sort Data in Descending Using JavaScript - Delft Stack

    Mar 11, 2025 · Learn how to sort array data in descending order using JavaScript. This article covers default array methods and custom sorting functions, providing practical examples for …

  7. How can I sort an array in descending order in JavaScript?

    To sort an array in descending order in JavaScript, you can use the sort() method with a custom comparison function. Here's a step-by-step guide on how to achieve this: 1. Create an array: …

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

    May 16, 2023 · 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 elements in the array in …

  9. JavaScript Array sort () Method - GeeksforGeeks

    Nov 12, 2024 · We can use the string.localeCompare () method in the comparator function to sort in reverse order. We can also use the array.reverse () method to sort the array in descending …

  10. 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.

  11. Some results have been removed