'''python实现冒泡排序''' def maopao(list): n = len(list) for i in range(1, n): #第几趟 for j in range(0, n-i): if list[j] > list[j+1]: temp = list[j] list[j] = list[j+1] list[j+1] = temp return list if __name__ == '__main__': list = [8,4,9,3,50,2,1,12,3,0.5] print(maopao(list))