@sorted_els = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, complex_calculation($_)] } @list; #### # swapped $a/$b to get max ($max_el) = map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { [$_, complex_calculation($_)] } @list;