Skip to content

Instantly share code, notes, and snippets.



Last active Dec 17, 2015
What would you like to do?
# Passes
def groupby(f, coll):
""" Group elements in collection by ``f`` """
d = dict()
for item in coll:
key = f(item)
if key not in d:
d[key] = []
return d

This comment has been minimized.

Copy link

@eigenhombre eigenhombre commented Jun 6, 2013


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment