-
-
Save dcbishop/6ddf0edf881ca3fddb6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template < typename value_t > | |
void BogoSort( std::vector< value_t > & data ) | |
{ | |
while( !std::is_sorted(data.cbegin(), data.cend()) ) | |
{ | |
std::shuffle(data.begin(), data.end()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
std::shuffle() requires a third parameter that provides uniform random numbers!
http://en.cppreference.com/w/cpp/algorithm/random_shuffle