Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 lurking in the Monastery: (4)
As of 2014-09-23 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls