title: android: jsonArray parsing with Array.sort
body: <p>My Code works fine. But it is complicate...</p>
  
  <p>I get my data via json</p>
  
  <pre><code>try{
              JSONArray matchdata = null;
              matchdata = json.getJSONArray("matchdata");
  </code></pre>
  
  <p>I want to filter only the finished Matches</p>
  
  <pre><code>for(int i=0;i&lt;matchdata.length();i++){
                      JSONObject e = matchdata.getJSONObject(i);
                      //only read finished Matchs  
                      if (e.getBoolean("match_is_finished") == true){
  </code></pre>
  
  <p>I controll the Nr. of finished Matches 126 is OK!</p>
  
  <pre><code>Log.e("id", String.valueOf(i));
  </code></pre>
  
  <p>I get my result in a Array and sort it:</p>
  
  <pre><code>Arrays.sort(addressArray, StandingsSort.ORDER_BY_RULES);
          //Print the sorted array
          for(int i=0; i&lt;addressArray.length; i++){
  
              mylist[i] = new String(addressArray[i].toString());
          }
  </code></pre>
  
  <p>The Code works fine when I delete the line: (and switch to a complete saison, where all matches are finished. 306 Matches)</p>
  
  <pre><code>if (e.getBoolean("match_is_finished") == true){
  </code></pre>
  
  <p>then I get all what I want. But when I Filter the result, the Array.sort does not work. Why?</p>
  
  <p>here ist the json <a href="http://openligadb-json.heroku.com/api/matchdata_by_league_saison?group_order_id=3&amp;league_saison=2013&amp;league_shortcut=bl1" rel="nofollow">link:</a></p>
  
  <pre><code>  },
    "league_name": "1. Fussball-Bundesliga 2013/2014",
    "match_is_finished": false,
    "match_date_time_utc": "2014-05-10T13:30:00+00:00",
    "id_team2": "7",
    "goals": null,
    "league_saison": "2013",
    "match_results": null,
    "group_id": "8820",
    "icon_url_team1": "http://www.openligadb.de/images/teamicons/Hertha_BSC.gif",
    "league_shortcut": "bl1",
    "group_order_id": "34",
    "icon_url_team2": "http://www.openligadb.de/images/teamicons/Borussia_Dortmund.gif",
    "last_update": "2013-06-21T22:57:04+00:00",
    "match_id": "24171",
    "name_team1": "Hertha BSC",
    "group_name": "34. Spieltag",
    "points_team1": "-1",
    "match_date_time": "2014-05-10T15:30:00+00:00",
    "name_team2": "Borussia Dortmund"
  }
  
  for(int i=0;i&lt;matchdata.length();i++){
                      JSONObject e = matchdata.getJSONObject(i);
                      //only read finished Matchs  "true".equals(e.getString("name"))
                      if (e.getBoolean("match_is_finished") == true){
                      //if (null != (e.getString("goals"))){
                      //calculate Points
                      int myVarGoal1 = Integer.valueOf(e.getString("points_team1"));
                      int myVarGoal2 = Integer.valueOf(e.getString("points_team2"));
                      if ((myVarGoal1) &gt; (myVarGoal2)){
                          myPoint1 = 3;
                          myPoint2 = 0;
                      }
                      if ((myVarGoal1) &lt; (myVarGoal2)){
                          myPoint1 = 0;
                          myPoint2 = 3;
                      }
                      if ((myVarGoal1) == (myVarGoal2)){
                          myPoint1 = 1;
                          myPoint2 = 1;
                      }
                      int calc1 = (map.get(e.getString("id_team1")) + myPoint1);
                      int calc2 = (map.get(e.getString("id_team2")) + myPoint2);
                      map.put("id",  Integer.valueOf(i));
                      map.put(e.getString("id_team1"), calc1);
                      map.put(e.getString("id_team2"), calc2);
  
                      //calculate Goals
                      int calcGoal1 = (map.get(e.getString("id_team1")+"G+") + myVarGoal1);
                      int calcGoal2 = (map.get(e.getString("id_team1")+"G-") + myVarGoal2);
                      int calcGoal3 = (map.get(e.getString("id_team2")+"G+") + myVarGoal2);
                      int calcGoal4 = (map.get(e.getString("id_team2")+"G-") + myVarGoal1);
                      map.put(e.getString("id_team1")+"G+", calcGoal1);
                      map.put(e.getString("id_team1")+"G-", calcGoal2);
                      map.put(e.getString("id_team2")+"G+", calcGoal3);
                      map.put(e.getString("id_team2")+"G-", calcGoal4);
  
                      Log.e("id", String.valueOf(i));
                      }
  </code></pre>