in reply to Sort Hash by Size of the Arrays it References
my %hash = (foo => [1..2], bar => [1..3], baz => [1]); my @keys = sort { @{$hash{$a}} <=> @{$hash{$b}} } keys %hash; print "$_ - @{$hash{$_}}", $/ for @keys; __output__ baz - 1 foo - 1 2 bar - 1 2 3
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re:x2 Sort Hash by Size of the Arrays it References (mention scalar context explicitly)
by grinder (Bishop) on May 02, 2002 at 13:41 UTC |