All problems

Reordering Names by Score

mediumPythonNumPyargsort

Fenwick College's quiz league sets the running order for the next round from the last round's results: the weakest scorer goes on first, so that the strongest player closes the evening. The results file holds one player per line — a name and that player's score — and it arrives in whatever order the marking happened to finish. No two players in a round share a score.

Task: Print the players' names in running order, weakest score first.

Input

The first line holds a single integer n, the number of players. Each of the next n lines holds a name and a score, separated by a single space. Names contain no spaces. No two scores are equal.

Output

n lines, one name per line, weakest score first. Print names only — the scores do not appear in the running order.

Example:

Input:
3
Alice 90
Bob 70
Cara 85

Output:
Bob
Cara
Alice

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…