sort json objects based on time order after I parse them :   
 Here is the code:
        I want to sort them based on time and/or date:
        They are already displayed, just not in order. For now, what I have are codes that parse json objects into xml. All I want to do is parsing them based on time and/or date. The item below is the example of JSON file where there are different dates and time(2 min ago, 5 min ago etc)
    
    
    
    try {
                // Create the root JSONObject from the JSON string.
                JSONObject jsonRootObject = new JSONObject(myjsonstring);
    
                //Get the instance of JSONArray that contains JSONObjects
                JSONArray jsonArray = jsonRootObject.getJSONArray("Postdetails");
    
                //Iterate the jsonArray and print the info of JSONObjects
                for(int i=0; i < jsonArray.length(); i++){
                    JSONObject jsonObject = jsonArray.getJSONObject(i);
                    //Collections.sort(jsonValues);
                    String text = jsonObject.optString("number_of_likes").toString();
                    String minute = jsonObject.optString("min_ago").toString();
                    //float salary = Float.parseFloat(jsonObject.optString("salary").toString());
                    time +=minute+"\n"+"\n"+"\n"+"\n"+"\n"+"\n"+"\n";
                    data += text;
    
                }
    
                output.setText(data);
                timeago.setText(time);
 

               } catch (JSONException e)
     {
    e.printStackTrace();
    }
    
    JSON file:
    
    
    {
    
        "Postdetails" :
        
        
        [
        
            
        
        {
        "min_ago": "2 min ago",
        "number_of_likes": "63",
        "number_of_comments": "92",
          "date": "7 March 2017"
        },
        
        {
        "min_ago":"5 min ago",
        "number_of_likes":"72",
        "number_of_comments":"123",
          "date":"7 March 2017"
        },
        
        {
          "min_ago":"9 min ago",
          "number_of_likes":"123",
          "number_of_comments":"9123",
          "date":"10 March 2017"
        },
          
        {
            "min_ago":"6 min ago",
            "number_of_likes":"133",
            "number_of_comments":"9123",
            "date":"9 March 2017"
          
        }
        
        
        ]
        }
    