def groupby_dict(dictionary, key):
return dict((k, list(g)) for k, g in itertools.groupby(sorted(list(dictionary.keys()), key=lambda name: dictionary[name][key]), key=lambda name: dictionary[name][key]))<EOL>
Group dict of dicts by key.