The way I see grouping is as an aggregation operation. As such, in my head, grouping is similar to min/max. However, if builtins are a no-go, then I feel I need to think a little outside the box:
Is there a possibility that there will be desired many more aggregate functions in the near future? Is there a case for collecting aggregate functions into another top level module? Also, I would consider statistics to have similarities - median, mean etc are aggregate functions. Histograms are also doing something similar to grouping.
Apologies I have not offered any concrete suggestions, but just thought I should offer my thoughts.