list中依据map<String,Object>的某个值排序

private void sort(List<Map<String, Object>> list) {
    	 Collections.sort(list, new Comparator<Map<String, Object>>(){
    	  public int compare(Map<String, Object> o1, Map<String, Object> o2) {    				  
          //依据map中某个字段,从小到大排序
   	   return  (Integer)o1.get("num")>(Integer)o2.get("num")?1:( (Integer)o1.get("num")==(Integer)o2.get("num")?0:-1);
    	   } 
    	  });
    }

posted @ 2017-04-30 14:57  yfceshi  阅读(255)  评论(0编辑  收藏  举报