두 가지 순위의 조건을 충족시키도록 정렬을 수행하라는 문제로 key를 이용하면 수월하게 해결할 수 있다고 생각했다.
import sys
N = int(input())
dot = []
for _ in range(N):
x, y = map(int, sys.stdin.readline().split())
dot.append([x, y])
dot.sort(key=lambda x : (x[0], x[1]))
for i in dot:
print(*i)