每天CookBook之Python-071

  • 使用堆排序合并序列
import heapq

a = [1, 4, 7, 10]
b = [2, 5, 6, 11]

for c in heapq.merge(a, b):
    print(c)

out

1
2
4
5
6
7
10
11
posted @ 2016-07-22 21:28  4Thing  阅读(83)  评论(0编辑  收藏  举报