code: public static <T> List<T> sort(Iterable<T> self, boolean mutate, Closure closure) {
          List<T> list = mutate ? asList(self) : toList(self);
          // use a comparator of one item or two
          int params = closure.getMaximumNumberOfParameters();
          if (params == 1) {
              Collections.sort(list, new OrderBy<T>(closure));
          } else {
              Collections.sort(list, new ClosureComparator<T>(closure));
          }
          return list;
      }
docs: Sorts this Iterable using the given Closure to determine the correct ordering. If the Iterable is a List
  and mutate is true, it is sorted in place and returned. Otherwise, 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 -> a.length() <=> b.length() }</pre>
  <pre class="groovyTestCase">
  def orig = ["hello","hi","Hey"]
  def sorted = orig.sort(false) { it.toUpperCase() }
  assert orig == ["hello","hi","Hey"]
  assert sorted == ["hello","Hey","hi"]
  </pre>
  
  @param self    the Iterable to be sorted
  @param mutate  false will always cause a new list to be created, true will mutate lists in place
  @param closure a 1 or 2 arg Closure used to determine the correct ordering
  @return a newly created sorted List
  @since 2.2.0