lambda1 [python] 람다(lambda) 정렬(sort) 람다 (lambda) lambda 매개변수 : 표현식 -------------------------- def 함수이름(매개변수): return 결과 lambda 매개변수 : 결과 정렬 "-"를 붙여줄 경우 반대가 됨! a = [값1, 값2, ...] sorted 오름 차순 : sorted(a, key = lambda x : x[0]) 내림 차순 : sorted(a, key = lambda x : -x[0]) sort 오름 차순 : a.sort(key = lambda x : x[0]) 내림 차순 : a.sort(key = lambda x : -x[0]) 인자가 2개일 경우 괄호로 묶어주며, 우선순위 순이다. a.sort(key = lambda x : (x[0], x[1])) arr = [[1,4], [3,.. 2023. 1. 14. 이전 1 다음