Write a Python code demonstrate the working of sorted() with lambda


Topic: Write a Python code demonstrate the working of sorted() with lambda

Solution

lis = [{ "name" : "Nandini", "age" : 20}, 
{ "name" : "Manjeet", "age" : 20 },
{ "name" : "Nikhil" , "age" : 19 }]
print ("The list printed sorting by age: ")
print (sorted(lis, key = lambda i: i['age']))
print ("\r")



List all Python Programs