public static JSonArray sortJsonArray(JSonArray array) { List<JSONObject> jsons = new ArrayList<JSONObject>(); for (int i = 0; i < array.length(); i++) { jsons.add(array.getJSonObject(i)); } Collections.sort(jsons, new Comparator<JSONObject>() { @Override public int compare(JSonObject lhs, JSonObject rhs) { String lid = lhs.getString("comment_id"); String rid = rhs.getString("comment_id"); // Here you could parse string id to integer and then compare. return lid.compareTo(rid); } }); return new JSonArray(jsons);}这段代码可以返回排序后的JSONArray,但是我仍然建议您将JSONObject解析为自己的数据bean,然后对它们进行排序。



