def should_sort_array_with_duplicate_using_counting_sort(): copy = [] copy[:] = arr = arrays.array(lower=10000, upper=30000) + arrays.array( lower=20000, upper=40000) + arrays.array(lower=1, upper=20000) counting_sort.sort(arr) assert not arr == copy assert arr == sorted(copy)
def testGeneralCase(self): A = [3, 1, 2, 5, 3, 1, 5, 2, 4] B = counting_sort.sort(A, 5) self.assertEqual(B, [1, 1, 2, 2, 3, 3, 4, 5, 5])
def should_sort_array_with_duplicate_using_counting_sort(): copy = [] copy[:] = arr = arrays.array(lower=10000, upper=30000) + arrays.array(lower=20000, upper=40000) + arrays.array(lower=1, upper=20000) counting_sort.sort(arr) assert not arr == copy assert arr == sorted(copy)
def should_sort_duplicate_using_counting_sort(): a = [2, 1, 1, 2, 2, 3, 4, 5] counting_sort.sort(a) assert sorted([2, 1, 1, 2, 2, 3, 4, 5]) == a
def test_sort(self): array = [6, 0, 4, 2, 3, 5, 10, 4, 8, 4, 2, 1, 5, 7, 8] self.assertEqual(sort(array), [0, 1, 2, 2, 3, 4, 4, 4, 5, 5, 6, 7, 8, 8, 10])
def counting_sort_rust(array): return counting_sort.sort(array)