code: @SuppressWarnings("unchecked")
      public static <T> T[] sort(T[] self, boolean mutate, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure closure) {
          T[] answer = (T[]) sort((Iterable<T>) toList(self), closure).toArray();
          if (mutate) {
              System.arraycopy(answer, 0, self, 0, answer.length);
          }
          return mutate ? self : answer;
      }
docs: Modifies this array so that its elements are in sorted order using the Closure to determine the correct ordering.
  If mutate is false, a new array is returned and the original array remains unchanged.
  Otherwise, the original array is sorted in place and returned.
  <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">
  def orig = ["hello","hi","Hey"] as String[]
  def sorted = orig.sort(false) { it.size() }
  assert orig == ["hello","hi","Hey"] as String[]
  assert sorted == ["hi","Hey","hello"] as String[]
  orig.sort(true) { it.size() }
  assert orig == ["hi","Hey","hello"] as String[]
  </pre>
  
  @param self    the array to be sorted
  @param mutate  false will always cause a new array to be created, true will mutate arrays in place
  @param closure a Closure used to determine the correct ordering
  @return the sorted array
  @since 1.8.1