nums = [3, 1, 2, 4, 5, 6]
k = n - 1
for i in range(n - 1):
for j in range(k):
if (nums[j] > nums[j + 1]):
nums[j], nums[j + 1] = nums[j + 1], nums[j]
ex_flag = True
if (ex_flag):
break
print(nums)
微信扫码预览、分享更方便