Sort-Map-By-Value
Sat 17 May 2025
title: "Sort Map by Value" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false
def sort_by_value(dict):
'''
'''
age_sorted = sorted(dict.items(), key=lambda x:x[1])
#print(age_sorted)
return age_sorted
age = {
'carl':40,
'alan':2,
'bob':1,
'danny':3
}
age_sorted = sort_by_value(age)
age_sorted
[('bob', 1), ('alan', 2), ('danny', 3), ('carl', 40)]
Score: 5
Category: basics