content: MANUAL_TEST = False
  
  def print_test[T](a: list[T], b: list[T]):
      if not MANUAL_TEST:
          print(a)
          return
  
      if len(a) != len(b):
          print(f"FAILED: length of a ({len(a)}) is not length of b ({len(b)})")
          return
  
      if len(a) == 0:
          print("PASSED")
          return
  
      for i in range(len(a)):
          if a[i] != b[i]:
              print(f"FAILED: element {i} of a is {a[i]} and is not equal to the element in b {b[i]}")
              return
  
      print("PASSED")
  
  ### Comparison Functions ###
  
  def compare_less(x: int, y: int) -> bool:
      return x < y
  
  def compare_greater(x: int, y: int) -> bool:
      return x > y
  
  def compare_string(x: str, y: str) -> bool:
      return x < y
  
  def compare_dict(x: dict[str,int], y: dict[str,int]) -> bool:
      return x["key"] < y["key"]
  
  ### Basic Sort Tests ###
  print_test(insertion_sort(list[int](), compare_less), list[int]()) # EXPECT: []
  print_test(insertion_sort([1, 2, 3], compare_less), [1, 2, 3]) # EXPECT: [1, 2, 3]
  print_test(insertion_sort([3, 2, 1], compare_less), [1, 2, 3]) # EXPECT: [1, 2, 3]
  print_test(insertion_sort([3, 2, 1], compare_greater), [3, 2, 1]) # EXPECT: [3, 2, 1]
  print_test(insertion_sort([1, 2, 3], compare_greater), [3, 2, 1]) # EXPECT: [3, 2, 1]
  
  print_test(heap_sort(list[int](), compare_less), list[int]()) # EXPECT: []
  print_test(heap_sort([1, 2, 3], compare_less), [1, 2, 3]) # EXPECT: [1, 2, 3]
  print_test(heap_sort([3, 2, 1], compare_less), [1, 2, 3]) # EXPECT: [1, 2, 3]
  print_test(heap_sort([3, 2, 1], compare_greater), [3, 2, 1]) # EXPECT: [3, 2, 1]
  print_test(heap_sort([1, 2, 3], compare_greater), [3, 2, 1]) # EXPECT: [3, 2, 1]
  
  print_test(pdq_sort(list[int](), compare_less), list[int]()) # EXPECT: []
  print_test(pdq_sort([1, 2, 3], compare_less), [1, 2, 3]) # EXPECT: [1, 2, 3]
  print_test(pdq_sort([3, 2, 1], compare_less), [1, 2, 3]) # EXPECT: [1, 2, 3]
  print_test(pdq_sort([3, 2, 1], compare_greater), [3, 2, 1]) # EXPECT: [3, 2, 1]
  print_test(pdq_sort([1, 2, 3], compare_greater), [3, 2, 1]) # EXPECT: [3, 2, 1]
  
  print_test(tim_sort(list[int](), compare_less), list[int]()) # EXPECT: []
  print_test(tim_sort([1, 2, 3], compare_less), [1, 2, 3]) # EXPECT: [1, 2, 3]
  print_test(tim_sort([3, 2, 1], compare_less), [1, 2, 3]) # EXPECT: [1, 2, 3]
  print_test(tim_sort([3, 2, 1], compare_greater), [3, 2, 1]) # EXPECT: [3, 2, 1]
  print_test(tim_sort([1, 2, 3], compare_greater), [3, 2, 1]) # EXPECT: [3, 2, 1]
  
  
  ### Sort Different Types ###
  words = ['The', 'quick', 'Brown', 'fox', 'Jumped', 'over', 'The', 'lazy', 'Dog']
  dicts = [{"key": 5}, {"key": 9}, {"key": 1}]
  
  print_test(insertion_sort(list[str](), compare_string), list[str]()) # EXPECT: []
  print_test(insertion_sort(words, compare_string), ['Brown', 'Dog', 'Jumped', 'The', 'The', 'fox', 'lazy', 'over', 'quick']) # EXPECT: ['Brown', 'Dog', 'Jumped', 'The', 'The', 'fox', 'lazy', 'over', 'quick']
  print_test(insertion_sort(dicts, compare_dict), [{"key": 1}, {"key": 5}, {"key": 9}]) # EXPECT: [{"key": 1}, {"key": 5}, {"key": 9}]
  
  print_test(heap_sort(list[str](), compare_string), list[str]()) # EXPECT: []
  print_test(heap_sort(words, compare_string), ['Brown', 'Dog', 'Jumped', 'The', 'The', 'fox', 'lazy', 'over', 'quick']) # EXPECT: ['Brown', 'Dog', 'Jumped', 'The', 'The', 'fox', 'lazy', 'over', 'quick']
  print_test(heap_sort(dicts, compare_dict), [{"key": 1}, {"key": 5}, {"key": 9}]) # EXPECT: [{"key": 1}, {"key": 5}, {"key": 9}]
  
  print_test(pdq_sort(list[str](), compare_string), list[str]()) # EXPECT: []
  print_test(pdq_sort(words, compare_string), ['Brown', 'Dog', 'Jumped', 'The', 'The', 'fox', 'lazy', 'over', 'quick']) # EXPECT: ['Brown', 'Dog', 'Jumped', 'The', 'The', 'fox', 'lazy', 'over', 'quick']
  print_test(pdq_sort(dicts, compare_dict), [{"key": 1}, {"key": 5}, {"key": 9}]) # EXPECT: [{"key": 1}, {"key": 5}, {"key": 9}]
  
  print_test(tim_sort(list[str](), compare_string), list[str]()) # EXPECT: []
  print_test(tim_sort(words, compare_string), ['Brown', 'Dog', 'Jumped', 'The', 'The', 'fox', 'lazy', 'over', 'quick']) # EXPECT: ['Brown', 'Dog', 'Jumped', 'The', 'The', 'fox', 'lazy', 'over', 'quick']
  print_test(tim_sort(dicts, compare_dict), [{"key": 1}, {"key": 5}, {"key": 9}]) # EXPECT: [{"key": 1}, {"key": 5}, {"key": 9}]
  
  ### Sort longer lists ###
  ordered = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
  ordered_r = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
  unordered = [98, 57, 39, 5, 70, 80, 93, 65, 96, 43, 99, 18, 26, 1, 46, 94, 55, 37, 95, 32, 49, 2, 24, 14, 9, 53, 64, 62, 16, 33, 77, 35, 69, 19, 44, 51, 76, 66, 52, 83, 38, 3, 20, 54, 100, 7, 6, 17, 84, 73, 58, 10, 11, 40, 15, 12, 68, 45, 81, 78, 30, 97, 13, 82, 79, 27, 22, 90, 74, 41, 29, 56, 50, 92, 71, 89, 72, 8, 91, 88, 23, 4, 59, 63, 36, 47, 86, 61, 25, 67, 34, 75, 85, 87, 31, 60, 42, 21, 28, 48]
  
  print_test(insertion_sort(ordered, compare_greater), [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) # EXPECT: [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
  print_test(insertion_sort(ordered_r, compare_less), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) # EXPECT: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
  print_test(insertion_sort(unordered, compare_less), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) # EXPECT: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
  
  print_test(heap_sort(ordered, compare_greater), [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) # EXPECT: [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
  print_test(heap_sort(ordered_r, compare_less), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) # EXPECT: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
  print_test(heap_sort(unordered, compare_less), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) # EXPECT: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
  
  print_test(pdq_sort(ordered, compare_greater), [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) # EXPECT: [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
  print_test(pdq_sort(ordered_r, compare_less), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) # EXPECT: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
  print_test(pdq_sort(unordered, compare_less), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) # EXPECT: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
  
  print_test(tim_sort(ordered, compare_greater), [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) # EXPECT: [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
  print_test(tim_sort(ordered_r, compare_less), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) # EXPECT: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
  print_test(tim_sort(unordered, compare_less), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) # EXPECT: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
  
  ### Testing Stability ###
  
  @test
  def test_stable():
      data_list = [{'key': 58, 'key2': 1}, {'key': 37, 'key2': 1}, {'key': 41, 'key2': 1}, {'key': 91, 'key2': 1}, {'key': 8, 'key2': 1}, {'key': 15, 'key2': 1}, {'key': 28, 'key2': 1}, {'key': 45, 'key2': 1}, {'key': 84, 'key2': 1}, {'key': 94, 'key2': 1}, {'key': 75, 'key2': 1}, {'key': 70, 'key2': 1}, {'key': 64, 'key2': 1}, {'key': 17, 'key2': 1}, {'key': 47, 'key2': 1}, {'key': 11, 'key2': 1}, {'key': 97, 'key2': 1}, {'key': 19, 'key2': 1}, {'key': 92, 'key2': 1}, {'key': 82, 'key2': 1}, {'key': 7, 'key2': 1}, {'key': 77, 'key2': 1}, {'key': 69, 'key2': 1}, {'key': 87, 'key2': 1}, {'key': 72, 'key2': 1}, {'key': 48, 'key2': 1}, {'key': 35, 'key2': 1}, {'key': 26, 'key2': 1}, {'key': 60, 'key2': 1}, {'key': 78, 'key2': 1}, {'key': 67, 'key2': 1}, {'key': 12, 'key2': 1}, {'key': 9, 'key2': 1}, {'key': 79, 'key2': 1}, {'key': 38, 'key2': 1}, {'key': 88, 'key2': 1}, {'key': 86, 'key2': 1}, {'key': 3, 'key2': 1}, {'key': 30, 'key2': 1}, {'key': 89, 'key2': 1}, {'key': 2, 'key2': 1}, {'key': 40, 'key2': 1}, {'key': 81, 'key2': 1}, {'key': 39, 'key2': 1}, {'key': 99, 'key2': 1}, {'key': 5, 'key2': 1}, {'key': 90, 'key2': 1}, {'key': 18, 'key2': 1}, {'key': 1, 'key2': 1}, {'key': 68, 'key2': 1}, {'key': 98, 'key2': 1}, {'key': 27, 'key2': 1}, {'key': 33, 'key2': 1}, {'key': 49, 'key2': 1}, {'key': 62, 'key2': 1}, {'key': 63, 'key2': 1}, {'key': 55, 'key2': 1}, {'key': 71, 'key2': 1}, {'key': 73, 'key2': 1}, {'key': 93, 'key2': 1}, {'key': 57, 'key2': 1}, {'key': 32, 'key2': 1}, {'key': 10, 'key2': 1}, {'key': 23, 'key2': 1}, {'key': 0, 'key2': 1}, {'key': 61, 'key2': 1}, {'key': 95, 'key2': 1}, {'key': 66, 'key2': 1}, {'key': 80, 'key2': 1}, {'key': 4, 'key2': 1}, {'key': 53, 'key2': 1}, {'key': 83, 'key2': 1}, {'key': 21, 'key2': 1}, {'key': 96, 'key2': 1}, {'key': 34, 'key2': 1}, {'key': 25, 'key2': 1}, {'key': 51, 'key2': 1}, {'key': 31, 'key2': 1}, {'key': 44, 'key2': 1}, {'key': 50, 'key2': 1}, {'key': 22, 'key2': 1}, {'key': 36, 'key2': 1}, {'key': 76, 'key2': 1}, {'key': 59, 'key2': 1}, {'key': 14, 'key2': 1}, {'key': 20, 'key2': 1}, {'key': 74, 'key2': 1}, {'key': 13, 'key2': 1}, {'key': 85, 'key2': 1}, {'key': 24, 'key2': 1}, {'key': 56, 'key2': 1}, {'key': 42, 'key2': 1}, {'key': 6, 'key2': 1}, {'key': 16, 'key2': 1}, {'key': 29, 'key2': 1}, {'key': 52, 'key2': 1}, {'key': 54, 'key2': 1}, {'key': 43, 'key2': 1}, {'key': 65, 'key2': 1}, {'key': 46, 'key2': 1}, {'key': 59, 'key2': 2}, {'key': 52, 'key2': 2}, {'key': 8, 'key2': 2}, {'key': 82, 'key2': 2}, {'key': 98, 'key2': 2}, {'key': 67, 'key2': 2}, {'key': 78, 'key2': 2}, {'key': 12, 'key2': 2}, {'key': 60, 'key2': 2}, {'key': 18, 'key2': 2}, {'key': 72, 'key2': 2}, {'key': 80, 'key2': 2}, {'key': 9, 'key2': 2}, {'key': 35, 'key2': 2}, {'key': 90, 'key2': 2}, {'key': 85, 'key2': 2}, {'key': 38, 'key2': 2}, {'key': 64, 'key2': 2}, {'key': 6, 'key2': 2}, {'key': 41, 'key2': 2}, {'key': 10, 'key2': 2}, {'key': 94, 'key2': 2}, {'key': 7, 'key2': 2}, {'key': 21, 'key2': 2}, {'key': 29, 'key2': 2}, {'key': 20, 'key2': 2}, {'key': 44, 'key2': 2}, {'key': 55, 'key2': 2}, {'key': 69, 'key2': 2}, {'key': 2, 'key2': 2}, {'key': 26, 'key2': 2}, {'key': 62, 'key2': 2}, {'key': 45, 'key2': 2}, {'key': 14, 'key2': 2}, {'key': 63, 'key2': 2}, {'key': 47, 'key2': 2}, {'key': 22, 'key2': 2}, {'key': 74, 'key2': 2}, {'key': 56, 'key2': 2}, {'key': 70, 'key2': 2}, {'key': 79, 'key2': 2}, {'key': 68, 'key2': 2}, {'key': 13, 'key2': 2}, {'key': 76, 'key2': 2}, {'key': 58, 'key2': 2}, {'key': 99, 'key2': 2}, {'key': 61, 'key2': 2}, {'key': 5, 'key2': 2}, {'key': 96, 'key2': 2}, {'key': 0, 'key2': 2}, {'key': 81, 'key2': 2}, {'key': 87, 'key2': 2}, {'key': 57, 'key2': 2}, {'key': 40, 'key2': 2}, {'key': 3, 'key2': 2}, {'key': 33, 'key2': 2}, {'key': 15, 'key2': 2}, {'key': 77, 'key2': 2}, {'key': 1, 'key2': 2}, {'key': 24, 'key2': 2}, {'key': 27, 'key2': 2}, {'key': 86, 'key2': 2}, {'key': 25, 'key2': 2}, {'key': 88, 'key2': 2}, {'key': 51, 'key2': 2}, {'key': 16, 'key2': 2}, {'key': 32, 'key2': 2}, {'key': 97, 'key2': 2}, {'key': 28, 'key2': 2}, {'key': 23, 'key2': 2}, {'key': 54, 'key2': 2}, {'key': 31, 'key2': 2}, {'key': 65, 'key2': 2}, {'key': 46, 'key2': 2}, {'key': 50, 'key2': 2}, {'key': 17, 'key2': 2}, {'key': 89, 'key2': 2}, {'key': 39, 'key2': 2}, {'key': 95, 'key2': 2}, {'key': 84, 'key2': 2}, {'key': 92, 'key2': 2}, {'key': 93, 'key2': 2}, {'key': 75, 'key2': 2}, {'key': 34, 'key2': 2}, {'key': 36, 'key2': 2}, {'key': 43, 'key2': 2}, {'key': 30, 'key2': 2}, {'key': 71, 'key2': 2}, {'key': 66, 'key2': 2}, {'key': 4, 'key2': 2}, {'key': 42, 'key2': 2}, {'key': 19, 'key2': 2}, {'key': 37, 'key2': 2}, {'key': 53, 'key2': 2}, {'key': 49, 'key2': 2}, {'key': 73, 'key2': 2}, {'key': 91, 'key2': 2}, {'key': 11, 'key2': 2}, {'key': 48, 'key2': 2}, {'key': 83, 'key2': 2}]
      sorted_list = [{'key': 0, 'key2': 1}, {'key': 0, 'key2': 2}, {'key': 1, 'key2': 1}, {'key': 1, 'key2': 2}, {'key': 2, 'key2': 1}, {'key': 2, 'key2': 2}, {'key': 3, 'key2': 1}, {'key': 3, 'key2': 2}, {'key': 4, 'key2': 1}, {'key': 4, 'key2': 2}, {'key': 5, 'key2': 1}, {'key': 5, 'key2': 2}, {'key': 6, 'key2': 1}, {'key': 6, 'key2': 2}, {'key': 7, 'key2': 1}, {'key': 7, 'key2': 2}, {'key': 8, 'key2': 1}, {'key': 8, 'key2': 2}, {'key': 9, 'key2': 1}, {'key': 9, 'key2': 2}, {'key': 10, 'key2': 1}, {'key': 10, 'key2': 2}, {'key': 11, 'key2': 1}, {'key': 11, 'key2': 2}, {'key': 12, 'key2': 1}, {'key': 12, 'key2': 2}, {'key': 13, 'key2': 1}, {'key': 13, 'key2': 2}, {'key': 14, 'key2': 1}, {'key': 14, 'key2': 2}, {'key': 15, 'key2': 1}, {'key': 15, 'key2': 2}, {'key': 16, 'key2': 1}, {'key': 16, 'key2': 2}, {'key': 17, 'key2': 1}, {'key': 17, 'key2': 2}, {'key': 18, 'key2': 1}, {'key': 18, 'key2': 2}, {'key': 19, 'key2': 1}, {'key': 19, 'key2': 2}, {'key': 20, 'key2': 1}, {'key': 20, 'key2': 2}, {'key': 21, 'key2': 1}, {'key': 21, 'key2': 2}, {'key': 22, 'key2': 1}, {'key': 22, 'key2': 2}, {'key': 23, 'key2': 1}, {'key': 23, 'key2': 2}, {'key': 24, 'key2': 1}, {'key': 24, 'key2': 2}, {'key': 25, 'key2': 1}, {'key': 25, 'key2': 2}, {'key': 26, 'key2': 1}, {'key': 26, 'key2': 2}, {'key': 27, 'key2': 1}, {'key': 27, 'key2': 2}, {'key': 28, 'key2': 1}, {'key': 28, 'key2': 2}, {'key': 29, 'key2': 1}, {'key': 29, 'key2': 2}, {'key': 30, 'key2': 1}, {'key': 30, 'key2': 2}, {'key': 31, 'key2': 1}, {'key': 31, 'key2': 2}, {'key': 32, 'key2': 1}, {'key': 32, 'key2': 2}, {'key': 33, 'key2': 1}, {'key': 33, 'key2': 2}, {'key': 34, 'key2': 1}, {'key': 34, 'key2': 2}, {'key': 35, 'key2': 1}, {'key': 35, 'key2': 2}, {'key': 36, 'key2': 1}, {'key': 36, 'key2': 2}, {'key': 37, 'key2': 1}, {'key': 37, 'key2': 2}, {'key': 38, 'key2': 1}, {'key': 38, 'key2': 2}, {'key': 39, 'key2': 1}, {'key': 39, 'key2': 2}, {'key': 40, 'key2': 1}, {'key': 40, 'key2': 2}, {'key': 41, 'key2': 1}, {'key': 41, 'key2': 2}, {'key': 42, 'key2': 1}, {'key': 42, 'key2': 2}, {'key': 43, 'key2': 1}, {'key': 43, 'key2': 2}, {'key': 44, 'key2': 1}, {'key': 44, 'key2': 2}, {'key': 45, 'key2': 1}, {'key': 45, 'key2': 2}, {'key': 46, 'key2': 1}, {'key': 46, 'key2': 2}, {'key': 47, 'key2': 1}, {'key': 47, 'key2': 2}, {'key': 48, 'key2': 1}, {'key': 48, 'key2': 2}, {'key': 49, 'key2': 1}, {'key': 49, 'key2': 2}, {'key': 50, 'key2': 1}, {'key': 50, 'key2': 2}, {'key': 51, 'key2': 1}, {'key': 51, 'key2': 2}, {'key': 52, 'key2': 1}, {'key': 52, 'key2': 2}, {'key': 53, 'key2': 1}, {'key': 53, 'key2': 2}, {'key': 54, 'key2': 1}, {'key': 54, 'key2': 2}, {'key': 55, 'key2': 1}, {'key': 55, 'key2': 2}, {'key': 56, 'key2': 1}, {'key': 56, 'key2': 2}, {'key': 57, 'key2': 1}, {'key': 57, 'key2': 2}, {'key': 58, 'key2': 1}, {'key': 58, 'key2': 2}, {'key': 59, 'key2': 1}, {'key': 59, 'key2': 2}, {'key': 60, 'key2': 1}, {'key': 60, 'key2': 2}, {'key': 61, 'key2': 1}, {'key': 61, 'key2': 2}, {'key': 62, 'key2': 1}, {'key': 62, 'key2': 2}, {'key': 63, 'key2': 1}, {'key': 63, 'key2': 2}, {'key': 64, 'key2': 1}, {'key': 64, 'key2': 2}, {'key': 65, 'key2': 1}, {'key': 65, 'key2': 2}, {'key': 66, 'key2': 1}, {'key': 66, 'key2': 2}, {'key': 67, 'key2': 1}, {'key': 67, 'key2': 2}, {'key': 68, 'key2': 1}, {'key': 68, 'key2': 2}, {'key': 69, 'key2': 1}, {'key': 69, 'key2': 2}, {'key': 70, 'key2': 1}, {'key': 70, 'key2': 2}, {'key': 71, 'key2': 1}, {'key': 71, 'key2': 2}, {'key': 72, 'key2': 1}, {'key': 72, 'key2': 2}, {'key': 73, 'key2': 1}, {'key': 73, 'key2': 2}, {'key': 74, 'key2': 1}, {'key': 74, 'key2': 2}, {'key': 75, 'key2': 1}, {'key': 75, 'key2': 2}, {'key': 76, 'key2': 1}, {'key': 76, 'key2': 2}, {'key': 77, 'key2': 1}, {'key': 77, 'key2': 2}, {'key': 78, 'key2': 1}, {'key': 78, 'key2': 2}, {'key': 79, 'key2': 1}, {'key': 79, 'key2': 2}, {'key': 80, 'key2': 1}, {'key': 80, 'key2': 2}, {'key': 81, 'key2': 1}, {'key': 81, 'key2': 2}, {'key': 82, 'key2': 1}, {'key': 82, 'key2': 2}, {'key': 83, 'key2': 1}, {'key': 83, 'key2': 2}, {'key': 84, 'key2': 1}, {'key': 84, 'key2': 2}, {'key': 85, 'key2': 1}, {'key': 85, 'key2': 2}, {'key': 86, 'key2': 1}, {'key': 86, 'key2': 2}, {'key': 87, 'key2': 1}, {'key': 87, 'key2': 2}, {'key': 88, 'key2': 1}, {'key': 88, 'key2': 2}, {'key': 89, 'key2': 1}, {'key': 89, 'key2': 2}, {'key': 90, 'key2': 1}, {'key': 90, 'key2': 2}, {'key': 91, 'key2': 1}, {'key': 91, 'key2': 2}, {'key': 92, 'key2': 1}, {'key': 92, 'key2': 2}, {'key': 93, 'key2': 1}, {'key': 93, 'key2': 2}, {'key': 94, 'key2': 1}, {'key': 94, 'key2': 2}, {'key': 95, 'key2': 1}, {'key': 95, 'key2': 2}, {'key': 96, 'key2': 1}, {'key': 96, 'key2': 2}, {'key': 97, 'key2': 1}, {'key': 97, 'key2': 2}, {'key': 98, 'key2': 1}, {'key': 98, 'key2': 2}, {'key': 99, 'key2': 1}, {'key': 99, 'key2': 2}]
      assert tim_sort(data_list, compare_dict) == sorted_list
  
  ### Stdlib sort tests ###
  print_test(sorted(list[int](), compare_less, reverse=True), list[int]()) # EXPECT: []
  print_test(sorted([3, 2, 1], reverse=True), [3, 2, 1]) # EXPECT: [3, 2, 1]
  print_test(sorted([1, 2, 3], compare_greater), [3, 2, 1]) # EXPECT: [3, 2, 1]
  print_test(sorted([1, 2, 3], compare_greater, reverse=True), [1, 2, 3]) # EXPECT: [1, 2, 3]
  
  