Code

Ticket #11008: dictsort.diff

File dictsort.diff, 821 bytes (added by ionut_bizau, 5 years ago)
Line 
1Index: django/template/defaultfilters.py
2===================================================================
3--- django/template/defaultfilters.py   (revision 10638)
4+++ django/template/defaultfilters.py   (working copy)
5@@ -469,7 +469,7 @@
6     """
7     var_resolve = Variable(arg).resolve
8     decorated = [(var_resolve(item), item) for item in value]
9-    decorated.sort()
10+    decorated.sort(lambda lhs, rhs: cmp(lhs[0], rhs[0]))
11     return [item[1] for item in decorated]
12 dictsort.is_safe = False
13 
14@@ -480,8 +480,7 @@
15     """
16     var_resolve = Variable(arg).resolve
17     decorated = [(var_resolve(item), item) for item in value]
18-    decorated.sort()
19-    decorated.reverse()
20+    decorated.sort(lambda lhs, rhs: -cmp(lhs[0], rhs[0]))
21     return [item[1] for item in decorated]
22 dictsortreversed.is_safe = False
23