堆排序(Python版)
coding:utf-8
'''
堆排序的实现
'''
import heapq
def HeapSort(list):
heapq.heapify(list)
heap = []
while list:
heap.append(heapq.heappop(list))
list[:] = heap
print list
'''
test
'''
mylist=[1,4,2,3,9,4,5,3]
HeapSort(mylist)
'''
堆排序的实现
'''
import heapq
def HeapSort(list):
heapq.heapify(list)
heap = []
while list:
heap.append(heapq.heappop(list))
list[:] = heap
print list
'''
test
'''
mylist=[1,4,2,3,9,4,5,3]
HeapSort(mylist)