Sorting Points by Coordinates
InterviewTime limit1sMemory limit256 MB
Sort N planar points by increasing x coordinate, breaking ties by increasing y, and print them in order.
- Level
Easy3 of 10
- Topics
- Sorting
- Solved
- No attempts yet
Problem
You are given points on a two-dimensional plane. Write a program that sorts the points by increasing coordinate, and by increasing coordinate when the coordinates are equal, then prints them.
Input
The first line contains the number of points (). Each of the next lines contains the coordinates and of the -th point, separated by a space (). All coordinates are integers, and no two points share the same position.
Output
Print the sorted points on lines, one point per line. On each line print the coordinate and the coordinate separated by a space.