Objective
sort accepts a key function that returns a tuple: it sorts by the first element and, on a tie, by the second, and so on. To reverse a numeric criterion just flip its sign.
Instructions
- Read an integer
nand thennlines withname age. - Show the people sorted by age from oldest to youngest and, for equal age, alphabetically by name. One person per line, formatted as
name age.
3
Ana 30
Luis 25
Eva 30
Ana 30
Eva 30
Luis 25
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise