Sort People by Age, then Name
Medium · Sorting
sorted() accepts a key function. If the key returns a tuple, Python compares the first values, then the second ones on a tie. To sort a number in descending order inside that tuple, negate it.
Write sort_people(people) where each person is a dict like {"name": "Ana", "age": 30}. Return the list of names, sorted by age (oldest first), then by name (A to Z) when ages are equal.
Next: Group Anagrams