Example #1
0
def heapsort(data,comp=lambda a,b:a>b):
    for i in reversed(range(len(data)//2)):
        heap.pushdown(data,i)
    last = len(data)-1
    for i in range(len(data)):
        data.enqueue(heap.pop(data,last))
        last-=1
Example #2
0
 def _make_heap(self):
     for i in reversed(range(len(self.data)//2)):
         heap.pushdown(self.data,i, comp=self.comp)