list<T> 排序

Collections.sort(resultList, new Comparator<HashMap<String, Object>>() {
@Override
public int compare(HashMap<String, Object> o1, HashMap<String, Object> o2) {

Date time1 = (Date) o1.get("submit_time");
Date time2 = (Date) o2.get("submit_time");
if (null == time1) {
return -1;
}
if (null == time2) {
return 1;
}
return time1.compareTo(time2);
}
});

return ResultMessage.getSuccess().setData(resultList);
}
  
原文地址:https://www.cnblogs.com/xdcr/p/7273692.html