summaryrefslogtreecommitdiff
path: root/django/utils/datastructures.py
diff options
context:
space:
mode:
authorMitar <mitar.github@tnode.com>2012-10-15 04:16:46 -0700
committerMitar <mitar.github@tnode.com>2012-10-15 04:16:46 -0700
commitc3fabb282d429de931ef10c91cee55700578eb86 (patch)
tree6c13bec5b267372ab2b98a8d8f20c84829f19e0c /django/utils/datastructures.py
parent58365401c92d2377c93def71d33165a77f36157b (diff)
downloaddjango-c3fabb282d429de931ef10c91cee55700578eb86.tar.gz
Allow reversed iteration over SortedDict.
Iterators cannot be reversed easily without this method.
Diffstat (limited to 'django/utils/datastructures.py')
-rw-r--r--django/utils/datastructures.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index ad17573104..d94a05dfb4 100644
--- a/django/utils/datastructures.py
+++ b/django/utils/datastructures.py
@@ -160,6 +160,9 @@ class SortedDict(dict):
def __iter__(self):
return iter(self.keyOrder)
+ def __reversed__(self):
+ return reversed(self.keyOrder)
+
def pop(self, k, *args):
result = super(SortedDict, self).pop(k, *args)
try: