多表关联查询中,对字段集合返回时,按照集合某一字段进行排序,例:
List<Map<String, Object>> resultList = new ArrayList<>();
注:该Map存在'voteStatus'
Collections.sort(resultList, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
Integer voteStatus = Integer.valueOf(o1.get("voteStatus").toString());
Integer voteStatus1 = Integer.valueOf(o2.get("voteStatus").toString());
return voteStatus.compareTo(voteStatus1);
}
});
}
本次操作为降序排列,升序可将return处值调换