Skip to content

Instantly share code, notes, and snippets.

@hakobe
Created September 9, 2008 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hakobe/9654 to your computer and use it in GitHub Desktop.
Save hakobe/9654 to your computer and use it in GitHub Desktop.
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