Last Updated: 3 Jan, 2026

Player Leaderboard Sorting

Easy
Asked in company
Signify Innovation Labs

Problem statement

You are developing a leaderboard system for a game. You are given a list of N players, where each player is represented by their name and their score.


Your task is to sort this list of players and print the resulting leaderboard according to two rules:

- Players should be sorted in descending order of their scores (highest score first).

- If two or more players have the same score, they should be sorted by their names in ascending lexicographical (alphabetical) order.


Input Format:
The first line of input contains an integer N, the number of players.

The next N lines each contain a player's name (a string) and their score (an integer), separated by a space.


Output Format:
The output should consist of N lines, each containing a player's name and score from the sorted list, separated by a space.


Note:
Player names will consist of only lowercase English letters and will not contain spaces.