标签:pre temp 查找 image 简单 shuff pos 图片 main
import random def foo(l): for i in range(1, len(l)): temp = l[i] pos = i for j in range(i - 1, -1, -1): if temp < l[j]: l[j + 1] = l[j] pos = j else: pos = j + 1 break l[pos] = temp return l if __name__ == ‘__main__‘: l = list(range(13)) random.shuffle(l) print(l) # [12, 0, 4, 5, 6, 2, 11, 10, 8, 7, 3, 1, 9] print(foo(l)) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
标签:pre temp 查找 image 简单 shuff pos 图片 main
原文地址:https://www.cnblogs.com/shijieli/p/10922566.html