def groupby(iterable, key=<NUM_LIT:0>, filter=None):
if isinstance(key, (basestring, int)):<EOL><INDENT>key = itemgetter(key)<EOL><DEDENT>elif isinstance(key, (tuple, list)):<EOL><INDENT>key = itemgetter(*key)<EOL><DEDENT>for label, grp in igroupby(iterable, key):<EOL><INDENT>yield label, list(grp)<EOL><DEDENT>
wrapper to itertools.groupby that returns a list of each group, rather
than a generator and accepts integers or strings as the key and
automatically converts them to callables with itemgetter(key)

Arguments:
    iterable: iterable
    key: string, int or callable that tells how to group

Returns:
    an iterable where each item is the key and a *list* of that
    group. (itertools.groupby returns a generator of that group).

e.g. groupby(iterable, 0)