From 1f5828eadfbe27c33a8f7c865a0d19664a2f1782 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Sat, 31 Aug 2024 04:05:53 +0300 Subject: [PATCH] fix: fix deprecation warning for macOS (#2711) Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> --- sorting/bogo_sort.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sorting/bogo_sort.cpp b/sorting/bogo_sort.cpp index 62fbef48e..749eaddd0 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; }