Sorting by two keys with stability
Rust
Medium
sorting
Task «Sorting by two keys with stability»
Write a program that reads a list of strings, each containing an integer and a string separated by a space. Sort the list in descending order by the integer, and for equal numbers, in ascending order by the string (lexicographically). Use a stable sort. Output the result in the same format.
Input Format
The first line contains an integer N (1 ≤ N ≤ 10^5). Then follow N lines, each containing an integer (absolute value ≤ 10^9) and a string (Latin letters, length ≤ 20).
Output Format
Output N lines in sorted order in the format "number string".
Examples
Example 1
INPUT
5
10
20
30
40
50
OUTPUT
5
150
10
50
Example 2
INPUT
4
apple
banana
cherry
date
OUTPUT
4
N/A
apple
date
main.rs