Acme-Sort-Bogosort
view release on metacpan or search on metacpan
lib/Acme/Sort/Bogosort.pm view on Meta::CPAN
);
The Bogosort has a worst case of O(INF), though as time approaches infinity the odds of not
finding a solution decline toward zero (assuming a good random number generator). The average
case is O( (n-1) * n! ). The n! term signifies how many shuffles will be required to obtain
a sorted result in the average case. However, there is no guarantee that any particular sort
will come in anywhere near average.
Keep in mind that a list of five items consumes an average of 5!, or 120 iterations. 10! is
3,628,800 shuffles. Also keep in mind that each shuffle itself is an O(n-1) operation.
Unless you need to heat a cold office with your processor avoid sorts on large data sets.
=head1 EXPORT
Always exports one function: C<bogosort()>.
=head1 SUBROUTINES/METHODS
=head2 bogosort( @unsorted )
Accepts a list as a parameter and returns a sorted list.
( run in 0.247 second using v1.01-cache-2.11-cpan-8d75d55dd25 )