https://www.acmicpc.net/problem/11650
# input
def custom_input():
# 점 개수
n = int(input())
# 좌표
dot_list = []
for _ in range(n):
dot_list.append(list(map(int, input().split())))
return dot_list
# 정렬
def solution(dot_list):
dot_list.sort(key = lambda x: (x[0], x[1]))
# dot_sorted = sorted(dot_list, key = lambda x: (x[0], x[1]))
for (x, y) in dot_list:
# for (x, y) in dot_sorted:
print("%d %d" %(x, y))
dot_list = custom_input()
solution(dot_list)
arr.sort(key = lambda x: (x[0], x[1]))
'''
lambda: input 값을 x라고 할 때
(x[0], x[1]): x[0]을 key값으로 설정하고,
x[0]이 같을 경우, x[1]을 기준으로 설정.
'''
dot_sorted = dot_list.sort(key = lambda x: (x[0], x[1]))
dot_list.sort(key = lambda x: (x[0], x[1]))
OR
dot_sorted = sorted(dot_list, key = lambda x: (x[0], x[1]))
...
for (x, y) in dot_sorted:
...
Merge, Quick, Insertion, Bubble,Selection 등 여러가지 정렬 알고리즘이 있는데,
과연 Python의 sort 함수는 어떤 정렬 알고리즘을 사용하는걸까?
Python은 TimeSort 알고리즘을 사용한다.!
** 네이버 기술 블로그에 설명이 잘되어 있다!
https://d2.naver.com/helloworld/0315536
[ x.sort(): 리스트형 메소드 ]
[ sorted(x): 파이썬 내장 함수 ]