[docs] [issue32709] the iterable for itertools.groupby must be sorted

Cheryl Sabella report at bugs.python.org
Mon Jan 29 07:49:59 EST 2018


Cheryl Sabella <chekat2 at gmail.com> added the comment:

It depends upon your use case.

In general, if you want it to work like SQL group by, then yes, it needs to be sorted, and I believe the documentation already covers that.  However, there are scenarios where you want to condense a string, but keep the ordering, such as:

'aaaaabbbbbbccccaaaaddd' into '5a6b4c4a3d'

and itertools.groupby works very nicely for that.

----------
nosy: +csabella

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32709>
_______________________________________


More information about the docs mailing list