Kodewick
Start learning →
Mini challenge←→0 / 80

Sports day table

#046Mini challengeSortingLists6 min

Sports day teams are noted as (team, points). Write standings(teams) with the most points first; when points tie, put the team names in alphabetical order. Return the team names; no teams gives [].

Examples
standings([("Red", 6), ("Blue", 9), ("Gold", 6)])→['Blue', 'Gold', 'Red']
standings([])→[]
main.py
def standings(teams):
    # your code here: a key that returns a tuple: the points made negative, then the name
    ordered = teams
    return [name for name, points in ordered]
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.