#快速排序 def func(arry): minarry = [] maxarry = [] if len(arry)<=1: return arry else: for i in arry[1:]: if i<arry[0]: minarry.append(i) else: maxarry.append(i) return func(minarry)+arry[0:1]+func(maxarry) a=[3,6,9,1,2,7] print(func(a)) #冒泡排序 def function(array): for i in range(len(array)-1): for j in range(len(array)-1-i): if array[j]>array[j+1]: array[j],array[j+1]=array[j+1],array[j] return array print(function(a))