Skip to content
Myr

[svn] fixed groupby (sorted has some weird behavior Oo)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent fecf882 · Browse files · 1 file+4 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−2 removed

  • other:+4 added−2 removed

1 file+4 added−2 removed

modified:jinja/filters.py+4 added-2 removed
8 unmodified lines
9 :license: BSD, see LICENSE for more details.10"""11import re12from random import choice13from operator import itemgetter14from urllib import urlencode, quote15from jinja.utils import urlize, escape, reversed, sorted, groupby16from jinja.datastructure import TemplateData17from jinja.exceptions import FilterArgumentError
859 unmodified lines
877 *New in Jinja 1.2*878 """879 def wrapped(env, context, value):880 expr = lambda x: env.get_attribute(x, attribute)880 return [{881 return sorted([{882 'grouper': a,883 'list': list(b)883 } for a, b in sorted(groupby(sorted(value, key=expr), expr))]884 } for a, b in groupby(sorted(value, key=expr), expr)],885 key=itemgetter('grouper'))886 return wrapped887888889FILTERS = {
48 unmodified lines