首页 > 代码库 > list中依据map<String,Object>的某个值排序

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);
    	   } 
    	  });
    }

list中依据map&lt;String,Object&gt;的某个值排序