@environmentfilter
def do_groupby(environment, value, attribute):
    expr = lambda x: environment.getitem(x, attribute)
    return sorted(map(_GroupTuple, groupby(sorted(value, key=expr), expr)))
Group a sequence of objects by a common attribute.
dataset/ETHPy150Open IanLewis/kay/kay/lib/jinja2/filters.py/do_groupby