a = 待排序列表 for i in range(len(a)): for j in range(0, I, -1): if a[j]<a[j-1]: swap(a[j], a[j-1]) else: break print(a)