package com.run.horus.earlywaring.common;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import net.sf.json.JSONArray;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
public class SortJsonArray {
public static JSONArray sortJsonArray(JSONArray array){
JSONArray sortedJsonArray = new JSONArray();
List jsonValues = new ArrayList();
for (int i = 0; i < array.size(); i++) {
jsonValues.add(array.getJSONObject(i));
}
Collections.sort(jsonValues, new Comparator() {
// You can change "Name" with "ID" if you want to sort by ID
private static final String KEY_NAME = "ID";
@Override
public int compare(JSONObject a, JSONObject b)