直接插入排序 ''' 最好的情况O(n^2) 最坏的情况O(n^2) 平均情况O(n^2) ''' def insert_sort(l): for i in range(1, len(l)): temp = l[i] j = i - 1 while l[j] > temp and j >= 0: l[j+1] = l[j] j -= 1 l[j+1] = temp