sort_by_score(records) where records is a list of (name, score) tuples. Return the list sorted by score descending; if scores tie, sort those names alphabetically ascending as a secondary key.records = [('Amit', 70), ('Zoya', 90), ('Bina', 90)][('Bina', 90), ('Zoya', 90), ('Amit', 70)]Bina and Zoya tie at 90 so they are ordered alphabetically; Amit trails at 70.
Use key=lambda r: (-r[1], r[0]) to sort by score desc, name asc in one pass.