On Tue, Jul 3, 2018 at 10:11 PM Chris Barker via Python-ideas <python-ideas@python.org> wrote:
* There are types of data well suited to the key function approach, and other data not so well suited to it. If you want to support the not as well suited use cases, you should have a value function as well and/or take a (key, value) pair.

* There are some nice advantages in flexibility to having a Grouping class, rather than simply a function.

The tri-grams example is interesting and shows some clever things you can do. The bi-grams example I wrote in my draft PEP could be extended to handle tri-grams with just a key-function, no value-function. However, because this example is fun it may be distracting from the core value of ``grouped`` or ``grouping``.

I don't think we need a nicer API for complex grouping tasks. As the tasks get increasingly sophisticated, any general-purpose API will be less nice than something built for that specific task.

Instead, I want the easiest possible interface for making groups for every-day use cases. The wide range of situations that ``sorted`` covers with just a key-function suggests that ``grouped`` should follow the same pattern.

I do think that the default, key=None, could be set to handle (key, value) pairs. But I'm still reluctant to break the standard of sorted, min, max, and groupby.