code: public static <G, K, V> Map<G, Map<K, V>> groupBy(Map<K, V> self, @ClosureParams(MapEntryOrKeyValue.class) Closure<G> closure) {
          final Map<G, List<Map.Entry<K, V>>> initial = groupEntriesBy(self, closure);
          final Map<G, Map<K, V>> answer = new LinkedHashMap<G, Map<K, V>>();
          for (Map.Entry<G, List<Map.Entry<K, V>>> outer : initial.entrySet()) {
              G key = outer.getKey();
              List<Map.Entry<K, V>> entries = outer.getValue();
              Map<K, V> target = createSimilarMap(self);
              putAll(target, entries);
              answer.put(key, target);
          }
          return answer;
      }
docs: Groups the members of a map into sub maps determined by the
  supplied mapping closure. The closure will be passed a Map.Entry or
  key and value (depending on the number of parameters the closure accepts)
  and should return the key that each item should be grouped under.  The
  resulting map will have an entry for each 'group' key returned by the
  closure, with values being the map members from the original map that
  belong to each group. (If instead of a map, you want a list of map entries
  use {code}groupEntriesBy{code}.)
  <p>
  If the <code>self</code> map is one of TreeMap, Hashtable or Properties,
  the returned Map will preserve that type, otherwise a LinkedHashMap will
  be returned.
  <pre class="groovyTestCase">def result = [a:1,b:2,c:3,d:4,e:5,f:6].groupBy { it.value % 2 }
  assert result == [0:[b:2, d:4, f:6], 1:[a:1, c:3, e:5]]</pre>
  
  @param self    a map to group
  @param closure a closure mapping entries on keys
  @return a new Map grouped by keys
  @since 1.0