code: public static <T> T[] sort(T[] self, boolean mutate, Comparator<? super T> comparator) {
          T[] answer = mutate ? self : self.clone();
          Arrays.sort(answer, comparator);
          return answer;
      }
docs: Modifies this array so that its elements are in sorted order as determined by the given comparator.
  If mutate is true, the array is sorted in place and returned. Otherwise, a new sorted
  array is returned and the original array remains unchanged.
  <pre class="groovyTestCase">
  def orig = ["hello","hi","Hey"] as String[]
  def sorted = orig.sort(false, String.CASE_INSENSITIVE_ORDER)
  assert orig == ["hello","hi","Hey"] as String[]
  assert sorted == ["hello","Hey","hi"] as String[]
  orig.sort(true, String.CASE_INSENSITIVE_ORDER)
  assert orig == ["hello","Hey","hi"] as String[]
  </pre>
  
  @param self       the array containing elements to be sorted
  @param mutate     false will always cause a new array to be created, true will mutate arrays in place
  @param comparator a Comparator used for the comparison
  @return a sorted array
  @since 1.8.1