Created
September 9, 2008 11:47
-
-
Save hakobe/9654 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub bubble_sort { | |
my ($array) = @_; | |
for my $i (0..$#$array) { | |
for my $j (0..($#$array-$i-1)) { | |
if ($array->[$j] > $array->[$j+1]) { | |
($array->[$j], $array->[$j+1]) = ($array->[$j+1], $array->[$j]); | |
} | |
} | |
} | |
return $array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment