본문 바로가기
Algorithm 💡/Sorting

[백준 10814번] 나이순 정렬

by 킹우현 2023. 2. 21.

import sys
input = sys.stdin.readline

n = int(input())

array = []

for i in range(n):
  age, name = list(input().split())
  array.append((int(age),name,i))

array.sort(key=lambda x:x[2])
array.sort(key=lambda x:x[0])

for i in range(n):
  print(f"{array[i][0]} {array[i][1]}")