Start with an iterable which needs to be grouped
lst = [("a", 5, 6), ("b", 2, 4), ("a", 2, 5), ("c", 2, 6)]
Generate the grouped generator, grouping by the second element in each tuple:
def testGroupBy(lst):
groups = itertools.groupby(lst, key=lambda...