#t551. 成绩排序
成绩排序
Sorting Grades
Problem Description
Given the grade list of a certain course in a class, sort and output the list by grade from high to low. If two students have the same grade, the one with the lexicographically smaller name comes first.
Input Format
The first line is an integer with , the number of students in the class.
The following lines each contain a student's name and his/her grade, separated by a single space. The name contains only letters and has length at most . The grade is a non-negative integer not greater than .
Output Format
Sort the grade list in descending order of grades and output it. Each line contains the name and the grade, separated by a single space.
Sample Input
4
Kitty 80
Hanmeimei 90
Joey 92
Tim 28
Sample Output
Joey 92
Hanmeimei 90
Kitty 80
Tim 28
Sample Explanation
There are students: Kitty scored , Hanmeimei , Joey , Tim . After sorting by grade from high to low, the order is Joey (), Hanmeimei (), Kitty (), Tim (). Since there are no equal grades, name lexicographic order is not needed, so the output is exactly the four lines above.
Constraints
; name length at most ; grade is a non-negative integer not greater than .