bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow monasterians,
I'm not sure whether I'm trying to sort an AoHoH or AoHoAoH, but I want to end up with an AoH ref for an HTML::Template loop that is sorted by month and then date, like:
July 12 golfing 20 retreat 29 marathon August...
Here's what I have now, but am getting different errors depending on how I treat the dereferencing in the "@s2_events" line, but the first sort (by month) is working.
#!/usr/bin/perl print "Content-type: text/plain\n\n"; use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use Data::Dumper; my $events = [ { month => 8, name => "August", list => [ { name => "retreat", date => 20 }, { name => "marathon", date => 29}, { name => "golfing" , date => 12} ] }, { month => 7, name => "July", list => [ { name => "high tea", date => 15 }, { name => "rafting" , date => 23 }, + { name => "picnic", date => 10 }, ] }, ]; my @s1_events = sort { $a->{month} <=> $b->{month} } @$events; print Dumper (@s1_events); my @s2_events = sort { $a->{list}{date} <=> $b->{list}{date} } @s1_eve +nts; print Dumper(@s2_events); #produces 'pseudo-hashes are deprecated error'
I've spent hours searching and haven't found anything that handles this complexity, so here I am back at the monastery. Thanks all.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting an AoHoH or AoHoAoH
by broquaint (Abbot) on Jun 23, 2004 at 03:04 UTC | |
|
Re: Sorting an AoHoH or AoHoAoH
by Ido (Hermit) on Jun 23, 2004 at 03:13 UTC | |
by bradcathey (Prior) on Jun 23, 2004 at 03:18 UTC | |
|
Re: Sorting an AoHoH or AoHoAoH
by bageler (Hermit) on Jun 23, 2004 at 03:06 UTC | |
by Ido (Hermit) on Jun 23, 2004 at 03:26 UTC | |
|
Re: Sorting an AoHoH or AoHoAoH
by markjugg (Curate) on Jun 23, 2004 at 16:40 UTC | |
by bradcathey (Prior) on Jun 23, 2004 at 16:57 UTC |