。。。
1 def insertSort(nums): 2 length = len(nums) 3 for i in range(1,length): 4 x = nums[i] 5 for j in range(i,-1,-1): 6 if x < nums[j-1]: 7 nums[j] = nums[j-1] 8 else: 9 break10 nums[j] = x11 return nums
本文共 351 字,大约阅读时间需要 1 分钟。
。。。
1 def insertSort(nums): 2 length = len(nums) 3 for i in range(1,length): 4 x = nums[i] 5 for j in range(i,-1,-1): 6 if x < nums[j-1]: 7 nums[j] = nums[j-1] 8 else: 9 break10 nums[j] = x11 return nums
转载于:https://www.cnblogs.com/NPC-assange/p/11452600.html