how to sort list python
a_list = [3,2,1]
a_list.sort()
sort list python
>>> a = [5, 2, 3, 1, 4]
>>> a.sort()
>>> a
[1, 2, 3, 4, 5]
python sort list
# example list, product name and prices
price_data = [['product 1', 320.0],
['product 2', 4387.0],
['product 3', 2491.0]]
# sort by price
print(sorted(price_data, key=lambda price: price[1]))
sort list in python
List_name.sort()
This will sort the given list in ascending order.
list sort python
>>> names = ['Harry', 'Suzy', 'Al', 'Mark']
>>> sorted(names)
['Al', 'Harry', 'Mark', 'Suzy']
>>> sorted(names, reverse=True)
['Suzy', 'Mark', 'Harry', 'Al']
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us