Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 데이터분석
- 값추가
- React
- DataFrame
- setstate
- 광명시버스분석
- plot in r
- barplot in r
- 배열삭제
- useState
- barplot
- 백준
- 값삭제
- getline
- 버스분석
- 이스케이프시퀀스
- 탈출문자
- await
- asynchronization
- 이용현황분석
- 배열추가
- R데이터형태
- 그대로 출력하기
- 백준 11718
- 백준 10172
- 그래픽
- 10172
- vetor
- R 그래프
- react #회원가입 #비밀번호비교
Archives
- Today
- Total
devlog_zz
[python] list sort() , sorted() 차이 본문
728x90
sort()는 원본 배열 수정, 리턴 값 None
배열.sort()
sorted()는 정렬된 값 리턴해줌
sorted(배열)
sort()
arr = [4,2,3,5,1,7,20]
print(arr.sort())
print(arr)
None # 리턴 값이 없음
[1, 2, 3, 4, 5, 7, 20] # 원본 배열이 수정됨
sorted()
arr = [4,2,3,5,1,7,20]
print(sorted(arr))
print(arr)
[1, 2, 3, 4, 5, 7, 20] # 정렬된 배열 리턴
[4, 2, 3, 5, 1, 7, 20] # 원본함수는 그대로
728x90
'Back End > python' 카테고리의 다른 글
[ python ] list 복사 ( copy() ) (0) | 2022.08.07 |
---|---|
[python] range() 함수 활용 - 감소하는 list 생성, 증가하는 list 생성 (0) | 2022.08.07 |
[python] list 일부 선택하기 arr[2:5] (0) | 2022.08.07 |
[python] list 최대값, 최소값 index (0) | 2022.08.07 |
[python] 몫, 나머지 구하기 (0) | 2022.08.07 |
Comments