含有hashmap的arraylist排序

按照hashmap中的key为name字段排序:

 private void descSort(final String order,String dir){
            Collections.sort(arrayList, new Comparator<HashMap<String,Object>>(){
                @Override
                public int compare(HashMap<String, Object> arg0,HashMap<String, Object> arg1) {
                    return ((String) arg1.get("name")).compareTo((String) arg0.get("name"));
                }
            });
    }

你可能感兴趣的:(含有hashmap的arraylist排序)