Collections.sort对数组进行排序 发表于 2018-06-15 1234567891011121314151617181920212223Collections.sort(countType, new Comparator<Map<String, String>>() { @Override public int compare(Map<String, String> o1, Map<String, String> o2) { String occupy1 = o1.get("occupy"); String substring1 = occupy1.substring(occupy1.indexOf("{") + 1, occupy1.length() - 1); String occupy2 = o2.get("occupy"); String substring2 = occupy2.substring(occupy2.indexOf("{") + 1, occupy2.length() - 1); int m1 = Integer.parseInt(substring1); int m2 = Integer.parseInt(substring2); if (m1 > m2) { //m1在m2后面 return 1; } else if (m1 < m2) { //m1在m2前面 return -1; } else { Toast.makeText(FYInspecRequireActivity.this, "返回数据存在问题,occupy有相同的,我无法解析", Toast.LENGTH_SHORT).show(); return 0; } }});