@author jackzhenguo
@desc
@tag
@version
@date 2020/04/03
使用 heapq 模块,首先对列表建堆,默认建立小根堆,调用len(nums) 次heapop:
import heapq as hq
nums_list = [18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1]
hq.heapify(nums_list)
s_result = [hq.heappop(nums_list) for _ in range(len(nums_list))]
print(s_result)