{"issue":{"created_at":"2011-11-26T19:24:54Z","state":"open","updated_at":"2011-11-26T21:05:11Z","user":{"gravatar_id":"d02f7988d633a63ec4f1f1f936e46178","id":254808,"url":"https://api.github.com/users/inmarelibero","login":"inmarelibero","avatar_url":"https://secure.gravatar.com/avatar/d02f7988d633a63ec4f1f1f936e46178?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":1,"body":"Let's put I have an array of Author objects (id, firstname, lastname), or an array of arrays like:\r\n\r\n    [\r\n        {'firstname': 'Woody', 'lastname': 'Allen'},\r\n        {'firstname': 'Wayne', 'lastname': 'Coover'},\r\n        ...\r\n    ]\r\n\r\nand I want to sort them by \"lastname\" object attribute or array index.\r\n\r\n\r\nThis pull request aims to improve the twig_sort_filter() function, allowing it to accept the attribute of an object or the index of an array a user wants to order an array with.\r\nIt can also sort hybrid arrays.\r\n\r\nSo then a user can use the Twig sort() function like:\r\n\r\n    {% for entity in authors | sort('firstname') %}\r\n        {{ entity.firstname }} {{ entity.lastname }} \r\n    {% endfor %}\r\n\r\nand for case sensitive comparation:\r\n\r\n    {% for entity in authors | sort('firstname', false) %}\r\n        {{ entity.firstname }} {{ entity.lastname }} \r\n    {% endfor %}","assignee":null,"number":535,"id":2356588,"labels":[],"pull_request":{"patch_url":"https://github.com/fabpot/Twig/pull/535.patch","html_url":"https://github.com/fabpot/Twig/pull/535","diff_url":"https://github.com/fabpot/Twig/pull/535.diff"},"title":"Array sorting by object property or array index","closed_at":null,"html_url":"https://github.com/fabpot/Twig/issues/535","milestone":null,"url":"https://api.github.com/repos/fabpot/Twig/issues/535"},"action":"created","comment":{"created_at":"2011-11-26T21:05:11Z","updated_at":"2011-11-26T21:05:11Z","user":{"gravatar_id":"b4ec98df44deb80b1576283152670358","id":216080,"url":"https://api.github.com/users/nikic","login":"nikic","avatar_url":"https://secure.gravatar.com/avatar/b4ec98df44deb80b1576283152670358?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"Alternatively we could think about getting closures / lambdas in Twig.","id":2883920,"url":"https://api.github.com/repos/fabpot/Twig/issues/comments/2883920"}}