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.
In reply to Sorting an AoHoH or AoHoAoH by bradcathey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |