Browse files

Allow reversed iteration over SortedDict.

Iterators cannot be reversed easily without this method.
  • Loading branch information...
1 parent 5836540 commit c3fabb282d429de931ef10c91cee55700578eb86 @mitar mitar committed Oct 15, 2012
Showing with 3 additions and 0 deletions.
  1. +3 −0 django/utils/datastructures.py
View
3 django/utils/datastructures.py
@@ -160,6 +160,9 @@ def __delitem__(self, key):
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:

0 comments on commit c3fabb2

Please sign in to comment.