in reply to Sorting an AoHoH or AoHoAoH

you could use a Schwartzian Transform, handy when you want to sort a multi dimensional data set by some subkey:
my @s1_events = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map {[$_, $_->{month}]} @$events;
and then when you want to print do something like
for my $ev (@s1_events) { my @sd = map {"\t$_->{date} $_->{name}\n"} sort {$a->{date} <=> $b->{date}} @{$ev->{list}}; print "$ev->{name}\n@sd\n"; }

Replies are listed 'Best First'.
Re^2: Sorting an AoHoH or AoHoAoH
by Ido (Hermit) on Jun 23, 2004 at 03:26 UTC
    Using the Schwartzian Transform is very efficient when you want to do something with which element, and sort it by the result. In that case, generating a new list with items and their generated sorting "keys", lets you process each item only once, instead of many times.
    But, in this case, you sort by an element of a hash, and the sort in the Schwartzian Transform must sort by an element of an array, so there's no gain. Actually, you lose, both time and simplicity.