Answers for "to sort a list in python"

1

how to sort a list in python

l=[1,3,2,5]
l= sorted(l)
print(l)
#output=[1, 2, 3, 5]
#or reverse the order:
l=[1,3,2,5]
l= sorted(l,reverse=True)
print(l)
#output=[5, 3, 2, 1]
Posted by: Guest on July-04-2020
0

list sort python

>>> names = ['Harry', 'Suzy', 'Al', 'Mark']
>>> sorted(names)
['Al', 'Harry', 'Mark', 'Suzy']
>>> sorted(names, reverse=True)
['Suzy', 'Mark', 'Harry', 'Al']
Posted by: Guest on July-15-2020

Code answers related to "to sort a list in python"

Python Answers by Framework

Browse Popular Code Answers by Language