版权声明:如需转载,请注明转载地址。 https://blog.csdn.net/oJohnny123/article/details/82085568
data_set = [ 9,1,22,9,31,-5,45,3,6,2,11 ]
loop = 0
for i in range(len(data_set)):
while i > 0 and data_set[i] < data_set[i-1]:# 右边小于左边相邻的值
tmp = data_set[i]
data_set[i] = data_set[i-1]
data_set[i-1] = tmp
i -= 1
print(data_set)