Introduction to Python

Sort pairs 2

Given a list of pairs, you are asked to sort them in increasing order based on the second element. So, when looking at the final list of the pairs, the second element should be a non-decreasing sequence.
The first line of the input contains a single integer n - the number of pairs. The next n lines contain 2 integers separated by a space.
The program should print n lines containing the resulting list. Each line should have two integers separated by a space.
3 10 4 12 1 6 7
12 1 10 4 6 7


Time limit: 1 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue