Dsa
Sorting
Medium
Video Game Scoreboard
You are managing a scoreboard for a video game. Each player's score needs to be printed in order of their score, with the highest score first. If two players have the same score, they should be sorted by their usernames in lexicographical order. Your program should read a list of players with their usernames and scores, and output the sorted list.
Input:
The first line contains an integer N (1 <= N <= 1000), the number of players.
The next N lines each contain a username (a string) and a score (an integer).
Output:
Print the sorted list of usernames, one per line.
Example:
Input:
3
PlayerOne 1500
PlayerTwo 2000
PlayerThree 1500
Output:
PlayerTwo
PlayerOne
PlayerThree
Key concepts
sortinglisttuples
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now