python
sort와 sorted
22gamin
2023. 11. 11. 00:41
list.sort()와 sorted(list)의 가장 큰 차이
- list.sort()와 본체의 리스트를 정렬해서 변환하는 것
- sorted(list)는 본체 리스트는 내버려두고, 정렬한 새로운 리스트를 반환하는 것
정렬할 데이터.sort()
sorted(정렬할 데이터)
sorted(정렬할 데이터, reverse 파라미터) -> 디폴트로는 reverse=False로 오름차순