Skip to main content

Practice ยท 3 of 3

Top N by Score

Implement top_n(players, n) where players is a list of (name, score) tuples. Return a list of the n highest scores' names, highest first. Break ties by keeping the earlier player first (stable sort).

Difficulty: intermediate

Back to lesson: Practice: Sorting with key