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])
Exemple #3
0
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)
Exemple #4
0
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 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
Exemple #7
0
def counting_sort_rust(array):
    return counting_sort.sort(array)