code: public static <T> List<T> toSorted(Iterable<T> self, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure closure) {
          Comparator<T> comparator = (closure.getMaximumNumberOfParameters() == 1) ? new OrderBy<T>(closure) : new ClosureComparator<T>(closure);
          return toSorted(self, comparator);
      }
docs: Sorts this Iterable using the given Closure to determine the correct ordering. The elements are first placed
  into a new list which is then sorted and returned - leaving the original Iterable unchanged.
  <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.
  <pre class="groovyTestCase">assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { it.length() }</pre>
  <pre class="groovyTestCase">assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { a, b {@code ->} a.length() {@code <=>} b.length() }</pre>
  
  @param self    the Iterable to be sorted
  @param closure a 1 or 2 arg Closure used to determine the correct ordering
  @return a newly created sorted List
  @see #toSorted(Iterable, Comparator)
  @since 2.4.0