Allow reversed iteration over SortedDict.

Iterators cannot be reversed easily without this method.
This commit is contained in:
Mitar 2012-10-15 04:16:46 -07:00
parent 58365401c9
commit c3fabb282d
1 changed files with 3 additions and 0 deletions

View File

@ -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: