{"issue":{"pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"state":"open","user":{"avatar_url":"https://secure.gravatar.com/avatar/d75fb1ac625866de2d2b64cd48279595?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"d75fb1ac625866de2d2b64cd48279595","url":"https://api.github.com/users/PhilipCammarata","login":"PhilipCammarata","id":140955},"milestone":null,"assignee":null,"labels":[],"updated_at":"2011-11-02T10:49:58Z","closed_at":null,"comments":1,"url":"https://api.github.com/repos/mitsuhiko/jinja2/issues/27","body":"Sorry if I am missing something but when using Flask/SQLAlchemy to query the database for a list of bookmarks and their categories I get some strange ordering.\n\n\t<section class=\"span-12\" id=\"category-bookmarks\">\n\t{% for category in category_bookmarks|groupby('category') %}\n\t\t<h2>{{ category.grouper.title }}</h2>\n\t\t<ul>\n\t\t\t{% for bookmark in category.list %}\n\t\t\t<li><img src=\"static/favicons/{{ bookmark.favicon }}\" /><a href=\"{{ bookmark.url }}\">{{ bookmark.title|trim }}</a></li>\n\t\t\t{% endfor %}\n\t\t</ul>\n\t{% endfor %}\n\t</section>\n\nCategory is a foreign_key and this does work but every time I reload the page my categories are displayed in what looks to me like a random order.  I pull the bookmarks via a SQLAlchemy call:\n\n    category_bookmarks = Bookmark.query.order_by(db.desc('created'))\n\nHow can I control how groupby orders my results?  Putting a |sort after \n\n    for category in category_bookmarks|groupby('category')\n\ndoesn't seem to effect it.\n","html_url":"https://github.com/mitsuhiko/jinja2/issues/27","number":27,"title":"Groupby Ordering","id":824866,"created_at":"2011-04-28T15:30:15Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/bca793b3ea6bb585d464c4751c8505ab?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"bca793b3ea6bb585d464c4751c8505ab","url":"https://api.github.com/users/wallunit","login":"wallunit","id":1525},"updated_at":"2011-11-02T10:49:58Z","url":"https://api.github.com/repos/mitsuhiko/jinja2/issues/comments/2601868","body":"The `groupby` filter, sorts the iterable by the given grouper. That is required by Python's `itertools.groupby` function that is used under the hood.","id":2601868,"created_at":"2011-11-02T10:49:58Z"}}