I’m trying to work through the problem below:
list_dict = [{‘pet’:[‘Bird’, ‘Frog’, ‘Hamster’]},
{‘id’: [123, 456, 789]},
{‘dog’: [‘Beagle’, ‘Labrador’, ‘Dalmatian’]}
]
The challenge is to print the sorted list by the ‘id’ column in descending order.
So far I’ve tried
result1 = sorted(list_dict, key=lambda k: list(k.items())[0])
print(result1) which prints:
[{‘dog’: [‘Beagle’, ‘Labrador’, ‘Dalmatian’]},
{‘id’: [123, 456, 789]},
{‘pet’: [‘Bird’, ‘Frog’, ‘Hamster’]}]
how can I get this to work?