1. sort()메서드
쉽게 리스트를 정리할 수 있다
리스트 순서는 영구적으로 바뀐다
1-1. sort reverse
wanted_countries = ['일본', '중국', '태국', '독일', '스위스']
wanted_countries.sort(reverse = True)
print(wanted_countries)
2. sorted()메서드
리스트의 원래 순서를 유지하면서 정렬된 순서로 표현 혹은 출력한다
2-1. sorted reverse
wanted_countries = ['일본', '중국', '태국', '독일', '스위스']
sorted_wanted_countries = sorted(wanted_countries, reverse = True)
print(sorted_wanted_countries)
3. reverse()메서드
: sort의 반대
'What I study > Python_details' 카테고리의 다른 글
[Python] value_counts() 와 sort_index() (0) | 2022.12.12 |
---|---|
[Python Numpy] np.concatenate()와 np.column_stack()의 차이점 (1) | 2022.12.06 |
[Python Pandas] pandas 주요 명령어 모음집 (0) | 2022.12.02 |
[Python] ModuleNotFoundError: No module named 'graphviz' 오류 해결하기 (0) | 2022.11.01 |
[Python] 선택 칼럼 제외해서 subset 만들기 (0) | 2022.10.12 |