import itertools


def sort_and_group(iterable, key):
    """Sort an iterable and group the items by the given key func"""
    groups = [
        (k, list(g)) for k, g in
        itertools.groupby(sorted(iterable, key=key), key=key)
    ]
    return groups