Object profitValue=map.getOrDefault("DividedData",null);
//
举例:profitValue={{"numOne":60,"numTow":39,"percentage":""},{"numOne":20,"numTow":39,"percentage":""},
{"numOne":35,"numTow":39,"percentage":""}}
JSONObject jsonObject = new JSONObject();
Gson gson = new Gson();
List<Map<String, Object>> jsonList = gson.fromJson(profitValue.toString(), new TypeToken<List<Map<String, Object>>>() {}.getType());
System.out.println("======"+jsonList);
List<Map<String, Object>> collect =null;
//numOne最小值升序序排序
collect = jsonList.stream().sorted(Comparator.comparing(PhcBusinessHostipalController::comparingByNumOne)
).collect(Collectors.toList());
System.out.println("======"+
collect );
List<Object> object = new ArrayList<>();
for (Object obj : collect) {
JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(obj));
object.add(json);
}
phcBusinessHostipal.setProfitValue(object.toString());
} else {
phcBusinessHostipal.setProfitValue(null);
}
public static Float
comparingByNumOne(Map<String, Object> map){
return Float.parseFloat(map.get("numOne").toString());
}