@environmentfilter
def do_groupby(environment, value, attribute):
 expr = make_attrgetter(environment, attribute)
 return [_GroupTuple(key, list(values)) for (key, values) in groupby(sorted(value, key=expr), expr)]

@ environmentfilter def do_groupby ( environment , value , attribute ) : expr = make_attrgetter ( environment , attribute ) return [ _GroupTuple ( key , list ( values ) ) for ( key , values ) in groupby ( sorted ( value , key = expr ) , expr ) ]
group a sequence of objects by a common attribute .