I wrote code that takes a string that holds a JSON data. I'm sorting my JSON object array by ID. When I'm using my method I get this exception: "org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]".
What am I missing here and how to solve it?
private static void ResortJsonByUseCaseID( String jsonArrStr )
{
    JSONArray jsonArr = new JSONArray(jsonArrStr);
    JSONArray sortedJsonArray = new JSONArray();
    List<JSONObject> jsonValues = new ArrayList<JSONObject>();
    for (int i = 0; i < jsonArr.length(); i++) {
        jsonValues.add(jsonArr.getJSONObject(i));
    }
    java.util.Collections.sort( jsonValues, new java.util.Comparator<JSONObject>() {
        private static final String KEY_NAME = "useCaseId";
        @Override
        public int compare(JSONObject a, JSONObject b) {
            String valA = new String();
            String valB = new String();
            try {
                valA = (String) a.get(KEY_NAME);
                valB = (String) b.get(KEY_NAME);
            }
            catch (JSONException e) {
                //do something
                int tal = 9;
            }
            return valA.compareTo(valB);
        }
    });
    for (int i = 0; i < jsonArr.length(); i++) {
        sortedJsonArray.put(jsonValues.get(i));
    }
    jsonArrStr = sortedJsonArray.toString();
}

