About 2,100,000 results
Open links in new tab
  1. sort() in Python - GeeksforGeeks

    May 5, 2025 · Explanation: a.sort(reverse=True) sorts the list in descending order, from Z to A, based on their Unicode code points. Example 2: In this example, we sort a list of strings by …

  2. Python list sort in descending order - Stack Overflow

    Mar 16, 2023 · Since your list is already in ascending order, we can simply reverse the list. Here is another way. Especially if the data is numeric, negation can be used to sort in descending …

  3. Python Sort List – How to Order By Descending or Ascending

    Sep 3, 2021 · In Python, you can sort data by using the sorted() method or sort() method. In this article, I will provide code examples for the sorted() and sort() methods and explain the …

  4. Sorting Techniques — Python 3.13.3 documentation

    2 days ago · Python lists have a built-in list.sort() method that modifies the list in-place. There is also a sorted() built-in function that builds a new sorted list from an iterable. In this document, …

  5. 5 Ways to Sort a Python List in Descending Order - TechBeamers

    Feb 10, 2024 · To achieve descending order, we can use the reverse parameter. In this example, sorted_list_desc contains the elements of the original list sorted in descending order. This …

  6. Python Sort List: A Complete Guide - PyTutorial

    Oct 28, 2024 · To sort a list in descending order, set the reverse parameter of sort() to True. This will reorder numbers to [9, 4, 2, 1]. sorted() returns a new sorted list, leaving the original list …

  7. Sorting of array in ascending and descending order in Python

    By using sort () function you can sort array into both ascending order and descending order by just using reverse=True or reverse=False. Example: Input. Output. Input size of array. Use …

  8. 5 Best Ways to Sort the Elements of an Array in Descending Order

    Mar 6, 2024 · By setting the reverse argument to True, we can sort the array in descending order. Here’s an example: Output: [9, 6, 5, 4, 3, 2, 1, 1] This code snippet creates an array called arr, …

  9. Sort Elements of an Array in Descending Order using Python

    Apr 16, 2021 · Learn how to sort the elements of an array in descending order using Python with this comprehensive guide and example.

  10. Efficiently sorting a numpy array in descending order?

    Nov 18, 2014 · temp[::-1].sort() sorts the array in place, whereas np.sort(temp)[::-1] creates a new array. Thanks, but how does temp[::-1].sort() know that it has to sort in reverse order?? The …

  11. Some results have been removed