Use the reverse key to sort descending order in Python. If True
, the sorted list is reversed (or sorted in Descending order).
list.sort(key=..., reverse=...)
Note: reverse parameter as an optional argument.
Example sort descending in Python
Simple example code Sort the List in Descending Order.
list_name.sort(reverse=True)
Sorting list of Integers in descending
numbers = [1, 3, 4, 2]
numbers.sort(reverse=True)
print(numbers)
Output:

Or use this code for the sorted() method.
sorted(list, reverse=True)
Do comment if you have any doubts or suggestions on this Python sort topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.