Does anybody know if Python has an equivalent to Java\'s SortedSet interface?
Heres what I\'m looking for: lets say I have an object of type foo
, and I know
If you only need the keys, and no associated value, Python offers sets:
s = set(a_list)
for k in sorted(s):
print k
However, you'll be sorting the set each time you do this. If that is too much overhead you may want to look at HeapQueues. They may not be as elegant and "Pythonic" but maybe they suit your needs.