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)
'문제풀이 > 백준' 카테고리의 다른 글
[python/파이썬] 백준 4673 - 셀프 넘버(실5) (0) | 2023.01.15 |
---|---|
[python/파이썬] 백준 2161 - 카드1(실5) (0) | 2023.01.15 |
[python/파이썬] 백준 11650 - 좌표 정렬하기(실5) (0) | 2023.01.15 |
[python/파이썬] 백준 5597 - 과제 안 내신 분..?(브5) (0) | 2023.01.11 |
[python/파이썬] 백준 2562 - 최댓값(브3) (0) | 2023.01.10 |