一:插入类排序
1,直接插入排序
def insert_sort(sort_list):
iter_len = len(sort_list)
if iter_len < 2:
return sort_list
for i in range(1, iter_len):
key = sort_list[i]
j = i - 1
while j >=0 and sort_list[j] > key:
sort_list[j + 1] = sort_list[j]
j -= 1
sort_list[j + 1] = key
return sort_list
list_ex = [7, 6, 5, 4, 3, 2, 1]
print list_ex
list_rx = insert_sort(list_ex)
print list_rx