티스토리 뷰
private static Map<String, Integer> sortByComparator(Map<String, Integer> unsortMap) { // Convert Map to List List<Map.Entry<String, Integer>> list = new LinkedList<Map.Entry<String, Integer>>(unsortMap.entrySet()); // Sort list with comparator, to compare the Map values Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() { public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) { return (o1.getValue()).compareTo(o2.getValue()); } }); // Convert sorted map back to a Map Map<String, Integer> sortedMap = new LinkedHashMap<String, Integer>(); for (Iterator<Map.Entry<String, Integer>> it = list.iterator(); it.hasNext();) { Map.Entry<String, Integer> entry = it.next(); sortedMap.put(entry.getKey(), entry.getValue()); } return sortedMap; } public static void printMap(Map<String, Integer> map) { for (Map.Entry<String, Integer> entry : map.entrySet()) { System.out.println("[Key] : " + entry.getKey() + " [Value] : " + entry.getValue()); } }
'Java' 카테고리의 다른 글
| java home 설정 (0) | 2015.10.14 |
|---|---|
| replace, split (0) | 2015.01.19 |
| Fileoutput (0) | 2015.01.19 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- nodejs
- MQ
- mongodb
- AWS
- Ai
- EC2
- TDD
- data mining
- 테스트
- 테스트 주도 개발
- SpringBoot
- 웹개발
- kafka
- Python #FastAPI
- GateWayApi
- 테스트주도개발
- Python
- fastapi
- 퀜트백
- 분산처리
- ai agent
- MSA
- 켄트 백
- langchain
- data crawling
- 웹서비스
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
글 보관함