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 (Pilgrim)
on Oct 16, 2006 at 18:54 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://578571]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-19 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found