Use the reverse key to sort descending order in Python. If
True, the sorted list is reversed (or sorted in Descending order).
Note: reverse parameter as an optional argument.
Example sort descending in Python
Simple example code Sort the List in Descending Order.
Sorting list of Integers in descending
numbers = [1, 3, 4, 2] numbers.sort(reverse=True) print(numbers)
Or use this code for the sorted() method.
Do comment if you have any doubts or suggestions on this Python sort topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
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.