Stefan Behnel wrote:

Kent Johnson wrote:

heapq.nlargest()
heapq.nsmallest()


On second thought, that doesn't actually get me very far. I do not know in advance how many I must select since I need to remove duplicates *after* sorting (they are not necessarily 'duplicate' enough to fall into the same sort bucket). What I'd like to do is heapify and then create an iterator for the result. But since heapify doesn't support "reverse" ...

Any other ideas?

Wrap your data in a class that defines __cmp__ as the inverse of __cmp__ on the underlying data, then use heapq?
Just sort the list?


Kent


Stefan
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to