code: public static <K, V> Map<K, V> sort(Map<K, V> self, Comparator<K> comparator) {
          Map<K, V> result = new TreeMap<K, V>(comparator);
          result.putAll(self);
          return result;
      }
docs: Sorts the elements from the given map into a new ordered Map using
  the specified key comparator to determine the ordering.
  The original map is unchanged.
  <pre class="groovyTestCase">def map = [ba:3, cz:6, ab:5].sort({ a, b -> a[-1] <=> b[-1] } as Comparator)
  assert map*.value == [3, 5, 6]</pre>
  
  @param self the original unsorted map
  @param comparator a Comparator
  @return the sorted map
  @since 1.7.2