728x90
    
    
  
학습내용
정렬에 대한 내용을 전체적으로 정리해보고자 한다
정렬 관련해서 코드 필요할 때 들어와서 확인하는 용도
다중 정렬
def multisort(xs, specs):
    for key, reverse in reversed(specs):
        xs.sort(key=attrgetter(key), reverse=reverse)
    return xs
multisort(list(student_objects), (('grade', True), ('age', False)))
다중 정렬 문제 예시
문제를 통해 이해하는 것이 더 쉬울 것 같아 문제를 추가한다
[백준] 국영수
파이썬 정렬 관련 참고 링크
https://docs.python.org/ko/3/howto/sorting.html
Sorting Techniques
Author, Andrew Dalke and Raymond Hettinger,. Python lists have a built-in list.sort() method that modifies the list in-place. There is also a sorted() built-in function that builds a new sorted lis...
docs.python.org
→ 들어가서 유용한 정보 얻을 수 있음
728x90
    
    
  'PYTHON > 개념정리' 카테고리의 다른 글
| [DFS] 재귀 완벽히 이해하기 (2) | 2024.05.10 | 
|---|---|
| [Greedy] 그리디 (1) | 2024.05.09 | 
| [DFS/BFS] DFS, BFS (1) | 2024.05.09 |