in reply to Sorting HoHoA based on Length of Second Key

Can there be keys of different length in one? Can there be a different number of keys?

I'll write this to sort by mean key length. Let's just assign an array to the sorted keys so we don't have to worry about the print loop. A Schwartzian Transform seems like a good idea for this.

my @by_mean = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, length(join '', keys %{$HoHoA{$_}})/keys(%{$HoHoA{$_}})] } keys %HoHoA;
The ST lets you do the real calculation once per element, instead of repetitively in the sort comparisons.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Sorting HoHoA based on Length of Second Key
by Anonymous Monk on Jul 21, 2005 at 03:15 UTC
    Dear Mr Zaxo,
    As for your questions:
    Can there be keys of different length in one?
    NO.
    Can there be a different number of keys?
    YES.