39std::vector<T>
dnfSort(
const std::vector<T> &in_arr) {
40 std::vector<T> arr(in_arr);
42 uint64_t hi = arr.size() - 1;
51 std::swap(arr[lo++], arr[mid++]);
61 std::swap(arr[mid], arr[hi--]);
77 std::vector<uint64_t> array1 = {0, 1, 1, 2};
78 std::cout <<
"Test 1... ";
79 std::vector<uint64_t> arr1 = sorting::dnf_sort::dnfSort(array1);
80 assert(std::is_sorted(std::begin(arr1), std::end(arr1)));
81 std::cout <<
"passed" << std::endl;
84 std::vector<uint64_t> array2 = {1, 0, 0, 1, 1, 0, 2, 1};
85 std::cout <<
"Test 2... ";
86 std::vector<uint64_t> arr2 = sorting::dnf_sort::dnfSort(array2);
87 assert(std::is_sorted(std::begin(arr2), std::end(arr2)));
88 std::cout <<
"passed" << std::endl;
91 std::vector<uint64_t> array3 = {1, 1, 0, 0, 1, 2, 2, 0, 2, 1};
92 std::cout <<
"Test 3... ";
93 std::vector<uint64_t> arr3 = sorting::dnf_sort::dnfSort(array3);
94 assert(std::is_sorted(std::begin(arr3), std::end(arr3)));
95 std::cout <<
"passed" << std::endl;
98 std::vector<uint64_t> array4 = {2, 2, 2, 0, 0, 1, 1};
99 std::cout <<
"Test 4... ";
100 std::vector<uint64_t> arr4 = sorting::dnf_sort::dnfSort(array4);
101 assert(std::is_sorted(std::begin(arr4), std::end(arr4)));
102 std::cout <<
"passed" << std::endl;