Acme-Sort-Bozo

 view release on metacpan or  search on metacpan

lib/Acme/Sort/Bozo.pm  view on Meta::CPAN

Acme::Sort::Bozo - Implementation of a Bozo sort algorithm.

=head1 VERSION

Version 0.05

=head1 SYNOPSIS

The Bozo is a sort that is based on a "swap and test" paradigm.  It works by 
first testing whether the input is in sorted order.  If so, return the list.  But if not, 
randomly select two elements from the list, swap them, and test again.  Repeat until 
the shuffle comes back sorted.

    use Acme::Sort::Bozo;

    my @unsorted = qw/ E B A C D /;
    my @ascending = bozo( @unsorted );
    
    my @descending = bozo(
        sub{ return $_[1] cmp $_[0]; },
        @unsorted



( run in 0.728 second using v1.01-cache-2.11-cpan-49f99fa48dc )