code: public static <T> T[] toSorted(T[] self, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure condition) {
          Comparator<T> comparator = (condition.getMaximumNumberOfParameters() == 1) ? new OrderBy<T>(condition) : new ClosureComparator<T>(condition);
          return toSorted(self, comparator);
      }
docs: Sorts the elements from this array into a newly created array using
  the Closure to determine the correct ordering.
  <p>
  If the closure has two parameters it is used like a traditional Comparator. I.e. it should compare
  its two parameters for order, returning a negative integer, zero, or a positive integer when the
  first parameter is less than, equal to, or greater than the second respectively. Otherwise,
  the Closure is assumed to take a single parameter and return a Comparable (typically an Integer)
  which is then used for further comparison.
  
  @param self the array containing the elements to be sorted
  @param condition a Closure used to determine the correct ordering
  @return a sorted array
  @see #toSorted(Object[], Comparator)
  @since 2.4.0