I want to sort that hash, and print only the values for the first keysDo you mean that for each key you want to sort the array associated with that key and then return the first (i.e. smallest value) in that array? If so, here's how to do that:
my %smallest; for my $k (keys %hash) { my $v = (sort { $a <=> $b } @{$hash{$k}})[0]; # assuming numeric val +ues $smallest{$k} = $v; }
In reply to Re: hash first value
by pc88mxer
in thread hash first value
by gfarhat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |