java List<Map> 排序问题


 Collections.sort(order_from_list, new Comparator<Map<Object, Object>>() {
            public int compare(Map<Object, Object> o1, Map<Object, Object> o2) {
                int map1value = (Integer) o1.get("pkey");
                int map2value = (Integer) o2.get("pkey");
                return map1value - map2value;
            }
        });

List list;想根据pkey大小排序,我写这个它报了类型不匹配,

    list格式:
    [
{
    stype=source_from,
    pkey=132,
    pname=BJ,
    codea=,
    codeb=,
    codec=,
    coded=,
    codee=,
    dflag=,
    sortby=2,
    vflag=add,
    comments=来源,
    source_from=SS
},
{
    stype=source_from,
    pkey=134,
    pname=DD,
    codea=,
    codeb=,
    codec=,
    coded=,
    codee=,
    dflag=,
    sortby=0,
    vflag=add,
    comments=来源,
    source_from=ECS
}

]

试试看
int map1value = ((Integer) o1.get("pkey")).intValue;
int map2value = ((Integer) o2.get("pkey")).intValue;

报的是sort
The method sort(List, Comparator<? super T>) in the type Collections is not applicable for the arguments (List, new Comparator>(){})

排序问题
希望对你有用