티스토리 뷰
728x90
import operator
dict = {'A':1, 'D':4, 'C':3, 'B':2}
# key
sort_dict = sorted(dict.items())
print(sort_dict)
# value
sort_dict = sorted(dict.items(), key=lambda x:x[1])
print(sort_dict)
[문법 / Python] 딕셔너리 정렬하기
딕셔너리를 정렬하는 방법들을 알아보겠습니다. 딕셔너리는 리스트처럼 sort()함수를 사용할 수 없기때문에 sorted()를 이용해서 정렬해야 합니다. KEY를 이용한 정렬 import operator dict = {'A':1, 'D':4, 'C
sinsomi.tistory.com
https://stackoverflow.com/questions/613183/how-do-i-sort-a-dictionary-by-value
How do I sort a dictionary by value?
I have a dictionary of values read from two fields in a database: a string field and a numeric field. The string field is unique, so that is the key of the dictionary. I can sort on the keys, but ...
stackoverflow.com
728x90
'공부' 카테고리의 다른 글
[Linux] nohup python3 app.py > log.txt 2>&1 & (0) | 2020.05.21 |
---|---|
[Python] calc for numpy (0) | 2020.05.21 |
[SpringBatch] Chunk (0) | 2020.05.21 |
[Python] int to binary (0) | 2020.05.20 |
[JS] get queryString (0) | 2020.05.18 |
댓글
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 팔로워 수 세기
- 테슬라 리퍼럴 코드
- 책그림
- 연애학개론
- 테슬라 리퍼럴 코드 혜택
- 테슬라 레퍼럴 적용 확인
- follower
- 테슬라
- 김달
- 클루지
- 레퍼럴
- 인스타그램
- 테슬라 레퍼럴
- 할인
- 테슬라 크레딧 사용
- 유투브
- 개리마커스
- 모델 Y 레퍼럴
- 테슬라 리퍼럴 코드 생성
- 어떻게 능력을 보여줄 것인가?
- COUNT
- Bot
- 메디파크 내과 전문의 의학박사 김영수
- wlw
- Kluge
- 테슬라 레퍼럴 코드 확인
- 모델y
- 테슬라 추천
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함