public static JsonArray sortJsonArray(JsonArray datasets) {
    ArrayList<JsonObject> datasetsList = new ArrayList<JsonObject>();
    for (JsonElement element : datasets) {
      datasetsList.add(element.getAsJsonObject());
    }

    Collections.sort( datasetsList, new Comparator<JsonObject>() {
      private String KEY_NAME = "flowtime";

      @Override
      public int compare(JsonObject a, JsonObject b) {
        Long valA = a.get(KEY_NAME).getAsLong();
        Long valB = b.get(KEY_NAME).getAsLong();
        return valA.compareTo(valB);
      }
    });

    datasets = new JsonArray();
    for (JsonObject element : datasetsList) {
      datasets.add(element);
    }
    return datasets;
  }
Sort the JsonArray given in parameters, based on the flowtime property,
from the most recent to the oldest.
app/com/linkedin/drelephant/util/Utils.java