[BaekJoon] 10814번: 나이순 정렬 (Python)
- Reference
- str로 받아왔으니 당연히 정렬은 int형으로 형변환을 해줬어야 했다.
Solution
import sys
from typing import List
def solution(members: List[List[str]]) -> List[List[str]]:
return sorted(members, key=lambda x: int(x[0]))
N = int(input())
members = []
for _ in range(N):
members.append(sys.stdin.readline().split())
answer = solution(members)
for i in range(N):
print(answer[i][0], answer[i][1])
Leave a comment