code: function groupBy(keySelector, elementSelector, resultSelector, keyComparator) {
              __assertFunction(keySelector);
              __assertFunction(elementSelector);
              __assert(__isUndefined(resultSelector) || __isFunction(resultSelector), 'resultSelector must be undefined or function!');
              __assertFunction(keyComparator);
              let groups = new Map();
              let result;
              for (let val of self) {
                  // Instead of checking groups.has we use our custom function since we want to treat some keys as equal even if they aren't for the Map
                  const key = __Collection.__getEqualKey(groups, keySelector(val), keyComparator);
                  const elem = elementSelector(val);
                  if (groups.has(key)) {
                      groups.get(key).push(elem);
                  }
                  else {
                      groups.set(key, [elem]);
                  }
              }
              if (resultSelector) {
                  // If we want to select the final result with the resultSelector, we use the built-in Select function and retrieve a new Collection
                  result = __Collection.from(groups).select((g) => resultSelector(...g));
              }
              else {
                  // our result is just the groups -> return the Map
                  result = groups;
              }
              return result;
          }
docs: /*
  This is the "basic" function to use. The others just transform their parameters to be used with this one.