Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dictsort template filter and filtering with two columns

In template for now I am using this:

{% for item in mydict|dictsortreversed:"column1" %}

But I have to sort data by two columns - is there any option in dictsort to do this? Or any alternative to do this in template?

like image 208
user606521 Avatar asked Feb 07 '13 14:02

user606521


1 Answers

As you can see in the Django code, there is no support for this.

However, since Python sorts in a stable way. This is trivial to implement by sorting twice :)

{% for item in mydict|dictsortreversed:"column1"|dictsortreversed:"column2" %}
like image 51
Wolph Avatar answered Oct 12 '22 23:10

Wolph