my @ordered = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_, expensive_function($_) ] } # such as lc() @unordered; # such as keys %hash