1 array = [1, 6, 7, 2, 9, 4] 2 for i in range(len(array)-1, 1, -1): 3 for j in range(0, i): 4 if array[j] > array[j+1]: 5 array[j], array[j+1] = array[j+1], array[j] 6 print(array) 7 8 results: 9 10 [1, 2, 4, 6, 7, 9]
1 array = [1, 6, 7, 2, 9, 4] 2 for i in range(len(array)-1, 1, -1): 3 for j in range(0, i): 4 if array[j] > array[j+1]: 5 array[j], array[j+1] = array[j+1], array[j] 6 print(array) 7 8 results: 9 10 [1, 2, 4, 6, 7, 9]