Answers for "python sort list with dict"

14

sort list of dictionaries by key python

newlist = sorted(list_to_be_sorted, key=lambda k: k['name'])
Posted by: Guest on March-25-2020
0

how to sort a dictionary py

orders = {
	'cappuccino': 54,
	'latte': 56,
	'espresso': 72,
	'americano': 48,
	'cortado': 41
}

sort_orders = sorted(orders.items(), key=lambda x: x[1], reverse=True)

for i in sort_orders:
	print(i[0], i[1])
Posted by: Guest on May-18-2021
-1

sort dict based on other list

orted_dict = dict()
sorted_list = list((i, unsorted_dict.get(i)) for i in ordination
Posted by: Guest on April-20-2020

Python Answers by Framework

Browse Popular Code Answers by Language