例子:Java中对list map根据map某个key值进行排序的方法
List<Map<String, Object>> productAttributeColors = new ArrayList<>();
//productAttributeColors 按 position 重新排序 start
Collections.sort(productAttributeColors, new Comparator<Map<String, Object>>() {
public int compare(Map<String, Object> map1, Map<String, Object> map2) {
Integer position1 = Integer.valueOf(map1.get("position").toString()) ;
Integer position2 = Integer.valueOf(map2.get("position").toString()) ;
return position1.compareTo(position2);
}
});
//productAttributeColors 按 position 重新排序 end