code: private static <T> ArrayList<T> sorted(Collection<T> cls, Comparator<? super T> c) {
      ArrayList<T> sorted = new ArrayList<>(cls);
      sorted.sort(c);
      return sorted;
    }
docs: Sort a collection of classes.
  
  @param cls Classes to sort
  @return Sorted list