Skip to content

Instantly share code, notes, and snippets.

@jrandom
Last active August 29, 2015 14:12
Show Gist options
  • Save jrandom/b4dd0d0f8200217c44d1 to your computer and use it in GitHub Desktop.
Save jrandom/b4dd0d0f8200217c44d1 to your computer and use it in GitHub Desktop.
Bogosort.cpp
template < typename container_t >
void BogoSort( container_t & data )
{
using std::begin;
using std::end;
std::random_device rd;
std::mt19937 ung( rd() );
while( !std::is_sorted(begin(data), end(data)) )
{
std::shuffle(begin(data), end(data), ung);
}
}
@wagle
Copy link

wagle commented Dec 27, 2014

Now make it a stable sort.. 8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment