Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Schwartzian Transform vs. Building Hash of Function Results, Then Sorting on Function Results

by davebaker (Monk)
on Oct 16, 2006 at 18:54 UTC ( #578571=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        my @output =
          map { $_->[0] }
          sort { $a->[1] cmp $b->[1] }
          map { [$_, expensive_func($_)] }
        @input;
    
  2. or download this
        foreach $_ (@input) {
            $result_for{$_} = expensive_func($_);
        }
    ...
        my @output
            = sort { $result_for{$a} cmp $result_for{$b}
                   } @input;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-08-23 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls