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; }