본문 바로가기

Computer Science/백준

[백준 / Python] 251: 수 정렬하기 2

728x90

문제

N개의 수가 주어졌을 때, 이를 오름차순으로 정렬하는 프로그램을 작성하시오.

My code

import sys

n = int(input())
num = []
for _ in range(n):
    num.append(int(sys.stdin.readline()))

num.sort()

for i in num:
    print(i)

TIL

  • Python 내장함수인 sort()는:
    • Stable Sort이다. 즉, 중복된 값의 경우 입력 순서와 동일하게 정렬한다.
    • O(NlogN)이다.
728x90