def bubbleSort(arr):
for i in range(len(arr) - 1):
for j in range(len(arr) - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
return arr
def main():
arr = [4, 2, 3, 6, 1, 7, 5, 9, 8, 10]
print('arr', arr)
arr1 = bubbleSort(arr)
print('arr1', arr1)
if __name__ == "__main__":
main()
网友评论