Skip to content

Instantly share code, notes, and snippets.

@Puriney
Created July 26, 2013 01:58
Show Gist options
  • Save Puriney/6085457 to your computer and use it in GitHub Desktop.
Save Puriney/6085457 to your computer and use it in GitHub Desktop.
PERL: Quick Sort
#http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Perl
sub quick_sort {
my @a = @_;
return @a if @a < 2;
my $p = pop @a;
quick_sort(grep $_ < $p, @a), $p, quick_sort(grep $_ >= $p, @a);
}
my @array = (1,4,2,3,6,5,8,7);
@array = quick_sort @array;
print "@array\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment