. Advertisement .
..3..
. Advertisement .
..4..
Computers are mostly used to store information and extract information from it. Python is one of the most powerful programming languages. We can use Python to get computers to do most routine processes. This blog is all about how we can sort a list in descending order in Python.
How Can You sort a list in descending order in Python?
You can sort a list in decreasing order by utilizing sort() and reverse in Python.
Syntax
|
Let’s consider the example of this:
Sample 1:
numList = [89,5,50,12,14,2]
numList.sort(reverse = True)
print(numList)
Result:
[89, 50, 14, 12, 5, 2]
Sample 2:
strList= ['Aa','Bb','Cc','Dd','Ee']
strList.sort(reverse = True)
print(strList)
Result:
['Ee', 'Dd', 'Cc', 'Bb', 'Aa']
Conclusion
Sorting a list in descending order in Python is a confusing problem. We hope this blog has helped clear the air around how to do it. If you have more questions about this topic, please comment below. Thank you for reading; we are always excited when one of our posts can provide useful information on a topic like this!
Leave a comment