본문 바로가기

코딩 테스트/백준

[Python] 백준 10814 나이순 정렬

 

정답 코드 

x[0]에 대해서 정수 변환 후 정렬을 해줘야 함..

import sys
input = sys.stdin.readline

n = int(input())
people = [list(input().split()) for _ in range(n)]

# people = sorted(people, key=lambda x : int(x[0]))
people.sort(key=lambda x : int(x[0]))

for age, name in people :
    print(age, name)