コード例 #1
0
ファイル: sort_test.py プロジェクト: benjamincrane/playground
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)
コード例 #2
0
 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])
コード例 #3
0
ファイル: sort_test.py プロジェクト: alexchao56/playground
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)
コード例 #4
0
ファイル: sort_test.py プロジェクト: alexchao56/playground
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
コード例 #5
0
 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])
コード例 #6
0
ファイル: sort_test.py プロジェクト: benjamincrane/playground
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
コード例 #7
0
def counting_sort_rust(array):
    return counting_sort.sort(array)