문제풀이/백준

[python/파이썬] 백준 10814 - 나이순 정렬(실5)

bbugi 2023. 1. 15. 04:13

https://www.acmicpc.net/problem/10814

 

10814번: 나이순 정렬

온라인 저지에 가입한 사람들의 나이와 이름이 가입한 순서대로 주어진다. 이때, 회원들을 나이가 증가하는 순으로, 나이가 같으면 먼저 가입한 사람이 앞에 오는 순서로 정렬하는 프로그램을

www.acmicpc.net


리스트 정렬하기 

두가지 형태의 인자를 받을 때 str로 받았다가

append할 때 데이터 형태 바꿔서 넣기

 

    x, y = list(map(str, input().split())) 
    m_list.append([int(x), y])


[문제 풀이]

import sys
input = sys.stdin.readline

n = int(input())

m_list = []
for _ in range(n):
    x, y = list(map(str, input().split())) 
    m_list.append([int(x), y])

sorted_m = sorted(m_list, key = lambda x : x[0])

for i in sorted_m:
    print(*i)