ram has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; my $list = [ '1','5','2','3','4' ]; my $len = @$list; my @temp = @$list; my @ref = @$list; my $pivot = pop @$list; my @temp1 = $pivot; my %ha = ; while ($len-1){ foreach my $ele (@temp){ next if ($ele eq $pivot); if ($ele gt $pivot) { push @temp1,$ele; } else{ unshift @temp1,$ele; } } print "\n @temp1 \n"; $pivot = pop @$list; print "$pivot \n"; @temp = @temp1; my $i=0; foreach my $ele(@ref){ if ($ele eq $pivot){ $ha{$i}="$ele"; print $ha{$i}; } $i++ } @temp1 =(); @temp1 = $pivot; --$len; } print keys %ha;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: quicksort implementation
by flexvault (Monsignor) on Oct 05, 2011 at 14:54 UTC | |
by ram (Initiate) on Oct 05, 2011 at 15:18 UTC | |
by davido (Cardinal) on Oct 05, 2011 at 17:18 UTC | |
by Anonymous Monk on Oct 06, 2011 at 04:52 UTC | |
by davido (Cardinal) on Oct 06, 2011 at 07:55 UTC | |
by choroba (Cardinal) on Oct 06, 2011 at 07:23 UTC | |
by choroba (Cardinal) on Oct 05, 2011 at 16:02 UTC | |
|
Re: quicksort implementation
by Anonymous Monk on Oct 05, 2011 at 11:38 UTC | |
by Anonymous Monk on Oct 05, 2011 at 13:08 UTC | |
by Anonymous Monk on Oct 05, 2011 at 14:00 UTC | |
by ram (Initiate) on Oct 05, 2011 at 15:41 UTC | |
by Anonymous Monk on Oct 06, 2011 at 02:37 UTC | |
by Anonymous Monk on Oct 05, 2011 at 14:26 UTC | |
by ram (Initiate) on Oct 05, 2011 at 14:59 UTC |