101. Sort Students by Marks
Core1000 ms256 MBSolved by 0%
Read n student records, each holding a name and a mark.
Print them ordered by mark, highest first. When two students have the same mark, keep them in the order they were given.
Print one student per line as name mark.
Constraints - `1 ≤ n ≤ 100000` - Names are 1 to 30 letters with no spaces. - `0 ≤ mark ≤ 1000`
Input
The first line contains an integer n.
Each of the next n lines contains a name and a mark.
Output
Print one student per line as name mark, highest mark first. Students on equal marks keep their input order.
Input3
Aravind 80
Divya 92
Nithya 75
OutputDivya 92
Aravind 80
Nithya 75
Notehas three distinct marks to reorder
Input3
A 50
B 50
C 50
OutputA 50
B 50
C 50
Notehas every mark equal, so the original order must survive exactly
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.