반응형 Collections2 HashMap 정렬(Key/Value) map에 대해서는 아래 참고 포스팅 참고 바란다. Map을 Key기준으로 정렬하기 위해서는 아래 코드와 같이 해결이 가능하다...이상 생략/ map 선언 되어있음List keySet = new ArrayList(map.keySet());// 키 값으로 오름차순 정렬Collections.sort(keySet);Collections에 대해서는 참고 포스팅 참고 바란다. Value 기준 정렬은 아래와 같다.Map map = new HashMap();map.put("a", 1);map.put("b", 3);map.put("c", 6);map.put("d", 9);map.put("e", 2);List keySetList = new ArrayList(map.keySet());// 오름차순System.out.prin.. 2024. 7. 29. Collections 함수에 대해 자바에서 List를 정렬하는 방법에 대해서는 간단히 sort 를 사용하여 가능하다.Arrays.sort();Arrays.sort(list);https://docs.oracle.com/javase/8/docs/api/ Java Platform SE 8 docs.oracle.com 그리고 또 다른방법으로는 Collections 를 사용하면 된다. https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html Collections (Java Platform SE 8 )Rotates the elements in the specified list by the specified distance. After calling this method, the el.. 2024. 7. 28. 이전 1 다음 반응형