santosh_br has asked for the wisdom of the Perl Monks concerning the following question:
sub bubbleSort { my @list = @_; my $sorted = 0; while ( not $sorted ) { $sorted = 1; # Innocent until proven guilty. for my $current ( 1 .. $#list ) { my $previous = $current - 1; if ( $list$current < $list$previous ) { ($list$current, $list$previous) = ($list$previous, $list$current); $sorted = 0; } } } return @list; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: while condition bubbleSort
by GrandFather (Saint) on Jul 17, 2008 at 03:46 UTC | |
|
Re^2: while condition bubbleSort
by eosbuddy (Scribe) on Jul 17, 2008 at 04:11 UTC | |
|
Re: while condition bubbleSort
by pjotrik (Friar) on Jul 17, 2008 at 08:18 UTC |