1. //dataJson为数据
    2. JSONObject sortJson = new JSONObject(new LinkedHashMap<>());
    3. List<String> keyList = new ArrayList<>();
    4. for (String key : dataJson.keySet()) {
    5. keyList.add(key);
    6. }
    7. Collections.sort(keyList,new Comparator<String>() {
    8. @Override
    9. public int compare(String str1, String str2) {
    10. return str2.compareTo(str1);
    11. }
    12. });
    13. for (String key : keyList) {
    14. sortJson.put(key, numberObj.getInteger(key));
    15. }