Skip to content

Instantly share code, notes, and snippets.

@mym0404
Created May 31, 2022 10:21
Show Gist options
  • Save mym0404/742c0c4a8ca539c7c089c5708d69dddd to your computer and use it in GitHub Desktop.
Save mym0404/742c0c4a8ca539c7c089c5708d69dddd to your computer and use it in GitHub Desktop.
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