Q:

Write a Python program to sort a list of nested dictionaries

0

Write a Python program to sort a list of nested dictionaries. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

my_list = [{'key': {'subkey': 1}}, {'key': {'subkey': 10}}, {'key': {'subkey': 5}}]
print("Original List: ")
print(my_list)
my_list.sort(key=lambda e: e['key']['subkey'], reverse=True)
print("Sorted List: ")
print(my_list)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now