sort in Python
Question:-
What is a large to small sort in Python?
sort in Python
sorting in python is quite easy in comparison to other programming languages.
it can be done in just one line in Python by using sort() method so firstly we should look at the syntax of it before using it and after that an example of it.
Let’s see-
Syntax:- list.sort(reverse=True|False, key=myFunc)
Example :-
- li=[1,4,5,6,5,8,669,52,255,8]
- li.sort(reverse=True)
- print(li)
Comments
Post a Comment