Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Fastest way to sort a list of integers into 0,1,2,3,-3,-2,-1

by Eily (Monsignor)
on Feb 05, 2019 at 17:40 UTC ( #1229425=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      GrepPos => sub{
        my @list = @input;
        my $pos =  grep { $_ >= 0 } @list;
        @list[$pos..$#list, 0..$pos-1] = sort {$a<=>$b} @list;
        Compare(\@list,\@output) or die "@list" if DO_CHECK;
      },
    
  2. or download this
                   Rate        Eily  Discipulus Discipulus3          vr
    Eily        21060/s          --        -55%        -61%        -65%
    Discipulus  47134/s        124%          --        -13%        -22%
    GrepPos     54377/s        158%         15%          --        -10%
    vr          60414/s        187%         28%         11%          --
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1229425]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (None)
    As of 2021-10-21 02:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (82 votes). Check out past polls.

      Notices?