Closed candychiu closed 8 years ago
Note: Just like Python's itertools.groupby, this doesn't do any sorting. It just iterates through, making a new group each time there is a key change. Thus, if the group is unsorted, the same key may appear multiple times.
This isn't unique to cppitertools, this is how groupby functions everywhere I've seen it. What you are asking for would require sorting the sequence before hand. That means the keys would need to be less-than comparable, and the sequence would at least need to have a ForwardIterator. If you want to get a sorted view of the sequence (but not sort the sequence itself) and then group on that, look at iter::sorted
Hi, I am trying to group_by a tuple key:
Instead of printing 2 lines, this example prints four lines. Does the groupby intent to work with group data not next to each other?