diff --git a/sorting/bogo_sort.cpp b/sorting/bogo_sort.cpp index 62fbef48ed6..749eaddd065 100644 --- a/sorting/bogo_sort.cpp +++ b/sorting/bogo_sort.cpp @@ -18,6 +18,7 @@ #include #include #include +#include /** @@ -50,8 +51,10 @@ std::array shuffle (std::array arr) { template std::array randomized_bogosort (std::array arr) { // Untill array is not sorted + std::random_device random_device; + std::mt19937 generator(random_device()); while (!std::is_sorted(arr.begin(), arr.end())) { - std::random_shuffle(arr.begin(), arr.end());// Shuffle the array + std::shuffle(arr.begin(), arr.end(), generator);// Shuffle the array } return arr; }