# coding:utf-8
__author__ = 'taohao'
"""
insert sort
"""
def insert_sort(array):
i = 1
while i < len(array):
tem = array[i]
j = i
while tem < array[j-1] and j > 0:
array[j] = array[j-1]
j -= 1
array[j] = tem
i += 1
if __name__ == '__main__':
array = [19, 3, 6, 99, 80, 39, 4, 2, 27, 50, 6, 75, 201, 98, 28, 91]
insert_sort(array)
print array
插入排序
最新推荐文章于 2017-03-26 15:24:22 发布