groupby which sorts the input, discards the key and returns the output
    as a sequence of lists.

def group(iterable, key):
    """
    groupby which sorts the input, discards the key and returns the output
    as a sequence of lists.
    """
    for _, grouped in groupby(sorted(iterable, key=key), key=key):
        yield list(grouped)