原文: http://106.13.73.98/__/46/
lst = [i for i in range(20, 0, -1)] length = len(lst) r = length // 2 while r: for i in range(length - r): if lst[i] > lst[i + r]: lst[i], lst[i + r] = lst[i + r], lst[i] r = r // 2 else: for i in range(length - 1): for i in range(i, -1, -1): if lst[i] > lst[i + 1]: lst[i], lst[i + 1] = lst[i + 1], lst[i]