builat has asked for the wisdom of the Perl Monks concerning the following question:
Perl: perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi
System: Debian GNU linux AMD64
Some creepy code:
#!/usr/bin/perl use strict; my (@out,$ref) = undef; #generating some rand data for(0..100){push @out,int (rand(300))+1;} #Take vector ref $ref = \@out; sortQ(0,$#out,$ref); #Qsort subr... sub sortQ{ my($s,$e,$dst)=@_; my$m=$s-1; for($s..$e-1){ if($dst->[$_] < $dst->[$e]){ $m++; ($dst->[$m],$dst->[$_])=($dst->[$_ +],$dst->[$m]); } } ++$m; ($dst->[$m],$dst->[$e])=($dst->[$e],$dst->[$m]); if($s<$m-1){sortQ($s,$m-1,$dst);} if($m+1<$e){sortQ($m+1,$e,$dst);} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: quick sort. How do it faster
by kcott (Archbishop) on Oct 20, 2013 at 05:15 UTC | |
|
Re: quick sort. How do it faster
by LanX (Saint) on Oct 20, 2013 at 02:57 UTC | |
by builat (Monk) on Oct 20, 2013 at 03:04 UTC | |
|
Re: quick sort. How do it faster
by tobyink (Canon) on Oct 20, 2013 at 07:41 UTC | |
by BrowserUk (Patriarch) on Oct 20, 2013 at 11:08 UTC | |
by tobyink (Canon) on Oct 23, 2013 at 13:50 UTC | |
by BrowserUk (Patriarch) on Oct 23, 2013 at 16:31 UTC | |
by LanX (Saint) on Oct 24, 2013 at 12:41 UTC | |
|
Re: quick sort. How do it faster
by AnomalousMonk (Archbishop) on Oct 20, 2013 at 16:27 UTC | |
by builat (Monk) on Oct 21, 2013 at 00:35 UTC |