import itertools


def group_and_create_lookup(things, key_func):
    """
    Takes list of things then sorts, groups, and
    returns a lookup with result of `key_func`
    as the key and list of things grouped on key
    as the value
    """
    things = things or []
    things = sorted(things, key=key_func)
    return {k: list(g) for k, g in itertools.groupby(things, key_func)}