java List排序

private void sortListByPriority(List resultList) {

    if (null != resultList && resultList.size() > 0) {
        Collections.sort(resultList, new Comparator<JSONObject>() {
            public int compare(JSONObject p1, JSONObject p2) {
                int returnNum = 0;
                if (null != p1 && null != p2) {
                    String priority1 = (String) p1.get("priority");
                    String priority2 = (String) p2.get("priority");
                    if (StringUtils.isNotBlank(priority1) && StringUtils.isNotBlank(priority2)) {
                        int tempP1 = Integer.parseInt(priority1);
                        int tempP2 = Integer.parseInt(priority2);
                        returnNum = tempP2 - tempP1;
                    }
                }
                return returnNum;
            }
        });
    }
}
上一篇:zookeeper集群搭建及java程序测试


下一篇:浏览器中禁用WebGL