Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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 chilling in the Monastery: (10)
As of 2014-07-28 13:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (198 votes), past polls