#_*_coding:utf-8-*- def Insert(x,n): i = 1; while i<=n-1: key = x[i] j = i-1 while j >= 0 and key<x[j]: x[j+1] = x[j] j -= 1 x[j+1] = key i+=1 return x list_test = [12,32,54,63,89,4,3,52,631,14,25] print("插入排序之前的数据:%s" %list_test) print("插入排序之后的数据:%s" %Insert(list_test,len(list_test)))
原文:http://www.cnblogs.com/blogofwyl/p/4526367.html