If you have no preference on the ordering of ties, then the ST part can be a bit simpler:print "$_ # Length ", length( ( keys %{ $HoHoA{ $_ } } )[ 0 ] ), "\n" for map $_->[ 0 ], sort { $a->[ 1 ] <=> $b->[ 1 ] || $a->[ 2 ] <=> $b->[ 2 ] } map [ $_, length( ( keys %{ $HoHoA{ $_ } } )[ 0 ] ), substr( $_, 3 ) + ], keys %HoHoA; __END__ set2 # Length 3 set3 # Length 3 set4 # Length 4 set1 # Length 7
These solutions assume that all the secondary hashes contain at least one key.map $_->[ 0 ], sort { $a->[ 1 ] <=> $b->[ 1 ] } map [ $_, length( ( keys %{ $HoHoA{ $_ } } )[ 0 ] ) ], keys %HoHoA;
the lowliest monk
In reply to Re: Sorting HoHoA based on Length of Second Key
by tlm
in thread Sorting HoHoA based on Length of Second Key
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |