def testMerge(n, mn, mx): L = random.sample(range(mn, mx), n) Sorts.merge(L) for i in range(len(L) - 2): if (L[i] > L[i + 1]): return False return True
def TimSort(array,n): for i in range(0,n,RUN): Sorts.insertionSort(array,i,min(i+RUN-1,n-1)) size=RUN while size < n: for x in range(0,n,size*2): array[x:x+2*size]=Sorts.merge(array[x:x+size],array[x+size:x+2*size]) size*=2