Hello guys. How are you all? I hope you all fine. In this tutorial we will learn about How to sort a list in descending order in python. so without wasting time lets learn about of this.
How to sort a list in descending order in python
- sort a list in descending order in python
to sort a list in descending order in python just Use sort() and reverse.By using Use sort() and reverse you can sort a list in descending order in python. Lets learn about of this by given below example:
num = [99,5,54,12,14,1] num.sort(reverse = True) print(num)
Output :[99, 54, 14, 12, 5, 1]
- How to sort a list in descending order in python
to sort a list in descending order in python just Use sort() and reverse. By using Use sort() and reverse you can sort a list in descending order in python. Lets learn about of this by given below example:
str= ['apple','ball','dog','cat','eleplant'] str.sort(reverse = True) print(str)
Output :['eleplant', 'dog', 'cat', 'ball', 'apple']
- python sort reverse
To sort a list in descending order in python just Use sort() and reverse. By using Use sort() and reverse you can sort a list in descending order in python. Lets learn about of this by given below example:
str= ['apple','ball','dog','cat','eleplant'] str.sort(reverse = True) print(str)
Output :['eleplant', 'dog', 'cat', 'ball', 'apple']
Method 1: Use sort() and reverse
By using Use sort() and reverse you can sort a list. Lets learn about of this by given below example:
num = [99,5,54,12,14,1]
num.sort(reverse = True)
print(num)
Output :
[99, 54, 14, 12, 5, 1]
Method 2: Use sort() and reverse
By using Use sort() and reverse you can sort a list. Lets learn about of this by given below example:
str= ['apple','ball','dog','cat','eleplant']
str.sort(reverse = True)
print(str)
Output :
['eleplant', 'dog', 'cat', 'ball', 'apple']
Conclusion
It’s all About this Tutorial. Hope all methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you?
Also, Read