//json 字符串
String dd = "[{id:1,adress:上海,age:21},{id:2,adress:上海,age:32},{id:3,adress:上海,age:28},{id:4,adress:上海,age:27}]";
//字符串转对象
JSONArray listObjectFifth = JSONObject.parseArray(dd);
//根据age升序序排序
listObjectFifth.sort(Comparator.comparing(obj -> ((JSONObject) obj).getBigDecimal("age")));
//根据age降序排序
listObjectFifth.sort(Comparator.comparing(obj -> ((JSONObject) obj).getBigDecimal("age")).reversed());