code: public static <K, V> Map<K, V> toSorted(Map<K, V> self, @ClosureParams(value=FromString.class, options={"Map.Entry<K,V>","Map.Entry<K,V>,Map.Entry<K,V>"}) Closure condition) {
          Comparator<Map.Entry<K,V>> comparator = (condition.getMaximumNumberOfParameters() == 1) ? new OrderBy<Map.Entry<K,V>>(condition) : new ClosureComparator<Map.Entry<K,V>>(condition);
          return toSorted(self, comparator);
      }
docs: Sorts the elements from the given map into a new ordered map using
  the supplied Closure condition as a comparator to determine the ordering. The original map is unchanged.
  <p>
  If the closure has two parameters it is used like a traditional Comparator. I.e. it should compare
  its two entry 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 entry parameter and return a Comparable (typically an Integer)
  which is then used for further comparison.
  <pre class="groovyTestCase">
  def map = [a:5, b:3, c:6, d:4].toSorted { a, b {@code ->} a.value {@code <=>} b.value }
  assert map.toString() == '[b:3, d:4, a:5, c:6]'
  </pre>
  
  @param self the original unsorted map
  @param condition a Closure used as a comparator
  @return the sorted map
  @since 2.4.0