Sorting a list of dictionaries by multiple keys

Report a typo
Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
How can you sort the Python list of dictionaries, 'data', first by the value of 'score' in descending order and then by 'age' in ascending order if scores are equal using 'sort()' function and a lambda function:
data = [{'name': 'John', 'score': 28, 'age': 30}, {'name': 'Jane', 'score': 28, 'age': 25}, {'name': 'Joe', 'score': 22, 'age': 40}]
Select one option from the list

Create a free account to access the full topic