Notice
Recent Posts
Recent Comments
Link
«   2025/06   »
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
Archives
Today
Total
관리 메뉴

유령노트

List<HashMap<String, Object>> 정렬 본문

JAVA

List<HashMap<String, Object>> 정렬

유령손 2018. 2. 13. 16:38
1
2
3
4
5
6
7
8
9
10
11
//정렬S
Collections.sort(/*정렬 할 리스트*/new Comparator<Map<String, Object >>() {
    @Override
    public int compare(Map<String, Object> first, Map<String, Object> second) {
        //스트링일시 변환 해서 대입용
        int a = Integer.parseInt((String) first.get("비교 Key 값")));
        int b = Integer.parseInt((String) second.get("비교 Key 값")));
        return a < b ? -1 : a > b ? 1:0;
    }
});
//정렬E
cs