code: public String sort(String json, String arrayExpr, String nestedPathExpr) {
          JsonPathHelper pathHelper = getPathHelper();
          Object topLevel = pathHelper.getJsonPath(json, arrayExpr);
          if (topLevel instanceof JSONArray) {
              JSONArray a = (JSONArray) topLevel;
              JSONArray aSorted = sort(pathHelper, a, nestedPathExpr);
              return pathHelper.updateJsonPathWithValue(json, arrayExpr, aSorted);
          } else {
              throw new IllegalArgumentException("Unable to find array using: " + arrayExpr);
          }
      }
docs: Sorts an array in a json object.
  @param json json document.
  @param arrayExpr JsonPath expression to select array to sort.
  @param nestedPathExpr JsonPath expression to select value of array's elements to sort them on.
  @return json document with specified array sorted.