question 96 Fundamentals Integration · medium
The podium is in alphabetical order
podium(results, places=3) should return the names of the fastest runners, fastest first. Results are (name, seconds) tuples. Runners with the same time are listed alphabetically. Right now it returns names in alphabetical order whatever their times, and after calling it the organisers' results list has been reshuffled. Fix both problems.
Function
podium(results, places=3)resultsa list of
(name, seconds) tuplesReturnsa new list of up to
places names, lowest time first; equal times in alphabetical orderMust notchange
resultsExamples
callpodium([('Ana', 1520), ('Ben', 1475), ('Chen', 1610), ('Dara', 1475), ('Eli', 1502)])returns['Ben', 'Dara', 'Eli']
callpodium([('Ana', 1520), ('Ben', 1475), ('Chen', 1610), ('Dara', 1475), ('Eli', 1502)], 1)returns['Ben']
callpodium([('Zed', 900), ('Amy', 950)])returns['Zed', 'Amy']