1 def merge(x:list, a:int, b:int, c:int):
4 while a < b and x[a] < x[b]:
9 while b < c and x[b - 1] < x[c - 1]:
15 x[b - w:b] = x[b:b + w]
22 def getrun(x:list, a:int, depth:int):
29 while b < len(x) and x[b - 1] < x[b]:
34 b = getrun(x, a, depth - 1)
35 c = getrun(x, b, depth - 1)
42 b = getrun(x, a, depth)
43 c = getrun(x, b, depth)
49 c = getrun(x, b, depth)
52 def is_sorted(x:list) -> bool:
53 for i in range(len(x) - 1):
58 if __name__ == '__main__':
59 import random, unittest
61 class SortTests(unittest.TestCase):
64 x = [i for i in range(25)]
67 self.assertTrue(is_sorted(x))