Sort Students by Score
You are given a list of student names and their corresponding scores. Sort the students based on their scores in descending order. If two students have the same score, their relative order should be maintained as in the original input (this is known as a stable sort). Print the names of the students in the sorted order.
Input
The first line contains an integer N, the number of students. The next N lines each contain a string (student name) and an integer (score), separated by a space.
Output
Print N lines, each containing a student name, in the order determined by the sorting criteria.
Constraints
1 <= N <= 1000. Student names consist of lowercase English letters and have length between 1 and 10. Scores are integers between 0 and 100.
Example 1
5 Alice 85 Bob 92 Charlie 78 David 92 Eve 85
Bob David Alice Eve Charlie
Bob and David have the same score (92), Bob appears before David in input, so Bob is printed first. Alice and Eve have score 85, Alice appears before Eve.
Example 2
3 Zoe 100 Amy 90 Ben 95
Zoe Ben Amy
Students are sorted by score in descending order.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
5 Alice 85 Bob 92 Charlie 78 David 92 Eve 85
3 Zoe 100 Amy 90 Ben 95