#冒泡排序 def bubbleSort(list): print(list) for j in range(len(list)-1,0,-1): print(list[j]) for i in range(j): if list[i]> list[i+1]:
tmp = list[i+1]
list[i+1]= list[i]
list[i]= tmp return list
#选择排序 def selectionSort(list): print(list) for x in range(len(list)):
min_index = x for j in range(x,len(list)): if list[min_index]> list[j]:
min_index = j if min_index != x:
tmp = list[x]
list[x]= list[min_index]
list[min_index]= tmp return list
#插入排序 def insertionSort(list): print(list) for x in range(1,len(list)):
tmp = list[x]
j = x-1 while j >= 0 and list[j]> tmp:
list[j+1]= list[j]
j = j-1
list[j+1]= tmp return list