in reply to List::Util max with block
@sorted_els = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, complex_calculation($_)] } @list;
I haven't tested the efficiency, but you might want to compare the other solutions with:
# swapped $a/$b to get max ($max_el) = map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { [$_, complex_calculation($_)] } @list;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: List::Util max with block
by ikegami (Patriarch) on Nov 06, 2009 at 21:15 UTC |