Stefan Behnel wrote:
Hi!
I need a general-purpose best-k sorting algorithm and I'd like to use heapq
for that (heapify + heappop*k). The problem is that heapify and heappop
do not
support the "reverse" keyword as known from sorted() and list.sort(). While
the decorate-sort-undecorate pattern allows me to replace the "key"
option, I
do not see an obvious way to have heapq work in a reverse way without
making
assumptions on the data.
heapq.nlargest()
heapq.nsmallest()
?
Python 2.4 only
Kent
--
http://mail.python.org/mailman/listinfo/python-list