Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

RFC: yet another sorting technique

by blazar (Canon)
on Jul 27, 2005 at 15:37 UTC ( [id://478647]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @sorted=do{
        my $n;
        my %stuff=map { func($_) . ':' . $n++ => $_ } @unsrt;
        @stuff{sort keys %stuff};
    };
    
  2. or download this
    my @sorted=do{
        my @keys=map func($unsrt[$_]) . ":$_", 0 .. $#unsrt;
        @unsrt[ map +(split /:/)[-1], sort @keys ];
    };
    
  3. or download this
    my @sorted=@unsrt[ map +(split /:/)[-1],
        sort map func($unsrt[$_]) . ":$_", 0 .. $#unsrt ];
    
  4. or download this
    my @sorted=map $unsrt[ (split /:/)[-1] ],
      sort map func($unsrt[$_]) . ":$_", 0 .. $#unsrt;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2024-04-18 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found