code: public List<QueryStats> getReportSortedBy(String sortByVal) {
          SortBy sortBy;
          try {
              sortBy = SortBy.valueOf(sortByVal);
          } catch (Exception e) {
              throw new IllegalArgumentException("allowed values are: " + Arrays.toString(SortBy.values()));
          }
  
          List<QueryStats> res = new ArrayList<>(statsByQuery.values());
          Collections.sort(res, sortBy.getComparator());
          return res;
      }
docs: Produces a report sorted by one of the accepted value.
  
  @param sortByVal - allowed values: "total", "avg", "min", "max", "count"
  @return  sorted list of query stats