Skip to content

Commit

Permalink
Note about order in groupy_transform
Browse files Browse the repository at this point in the history
  • Loading branch information
bbayles committed Apr 18, 2018
1 parent 703b1da commit 081f4f5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions more_itertools/more.py
Expand Up @@ -1345,6 +1345,10 @@ def groupby_transform(iterable, keyfunc=None, valuefunc=None):
>>> [(k, ''.join(g)) for k, g in grouper]
[(0, 'ab'), (1, 'cde'), (2, 'fgh'), (3, 'i')]
Note that the order of items in the iterable is significant.
Only adjacent items are grouped together, so if you don't want any duplicate
groups, you should sort the iterable by the key function.
"""
valuefunc = (lambda x: x) if valuefunc is None else valuefunc
return ((k, map(valuefunc, g)) for k, g in groupby(iterable, keyfunc))
Expand Down

0 comments on commit 081f4f5

Please sign in to comment.