on Thu, 29 Aug 2002 20:40:19 GMT, David Wagner wrote: > my %h = (); > > $h {"1"} = [ "some string","other string",3 ] ; > $h {"2"} = [ "some string","other string",2 ] ; > $h {"3"} = [ "some string","other string",1 ] ; > > foreach my $MyKey (sort { $a->[1]<=>$b->[1] } map{[$_,$h{$_}[2]]} > keys %h) { > printf "%-s -> %-s\n", $MyKey->[0], $MyKey->[1]; > } > > Output: > 3 -> 1 > 2 -> 2 > 1 -> 3
You don't need map in this case, a simple foreach my $MyKey ( sort { $h{$a}->[2] <=> $h{$b}->[2] } keys %h ) { printf "%-s -> %-s\n", $MyKey, $h{$MyKey}->[2]; } will work equally well without the need to create extra anonymous arrays. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]