#K46692. Custom Sort Problem

    ID: 28033 Type: Default 1000ms 256MiB

Custom Sort Problem

Custom Sort Problem

In this problem, you are given a list of records where each record consists of a name and a score. Your task is to sort the records in descending order by the score. If two records have the same score, they should be sorted in ascending lexicographical order by name.

The sorting criteria can be described as follows:

$$\text{If } score_1 > score_2, \text{ then record1 comes before record2.} $$$$\text{If } score_1 = score_2, \text{ then record1 comes before record2 if } name_1 < name_2. $$

Input is read from standard input and the result must be printed to standard output. Ensure that your output matches the expected format exactly.

inputFormat

The first line contains a single integer $$N$$ which represents the number of records. Each of the following $$N$$ lines contains a string and an integer separated by a space, representing the name and the score respectively.

outputFormat

Output the sorted list of records. Each record should be printed on a separate line with the name and score separated by a space.## sample

4
john 75
jane 85
doe 75
alice 90
alice 90

jane 85 doe 75 john 75

</p>