Created
May 31, 2022 10:21
-
-
Save mym0404/742c0c4a8ca539c7c089c5708d69dddd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import cmp_to_key | |
def my_cmp(a, b): | |
if a[1] != b[1]: | |
return a[1] - b[1] | |
return a[0] - b[0] | |
n = int(input()) | |
arr = [list(map(int, input().split())) for _ in range(n)] | |
arr.sort(key=cmp_to_key(my_cmp)) | |
for k in arr: | |
print(k[0], k[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment