Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^5: Sorting Template Toolkit Array of Hashrefs

by Anonymous Monk
on Jul 21, 2012 at 10:49 UTC ( #982966=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Sorting Template Toolkit Array of Hashrefs
in thread Sorting Template Toolkit Array of Hashrefs

So that begs the question ... how to turn the compound expression into a singular key?

Don't :)

If you view the source, you can see the current implementation

If you're smart enough you could alter it to accept  [ agendas', 0, 'agendaDate' ] to sort by agendas.0.agendaDate

If you're really smart, you'll do any such sorting/prep required from within perl and simplify the data structure you give the template ( adjust your "model" )


Comment on Re^5: Sorting Template Toolkit Array of Hashrefs
Download Code
Re^6: Sorting Template Toolkit Array of Hashrefs
by roho (Monsignor) on Jul 23, 2012 at 15:33 UTC
    Thanks for your reply. And thanks to my "really, really smart" co-worker who not only suggested sorting in Perl, but also provided an example of how to do it:

    my $sorted_results = [ sort { $a->{agendas}->[0]->{agendaDate} cmp $b- +>{agendas}->[0]->{agendaDate} } @$content ];

    "Its not how hard you work, its how much you get done."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://982966]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2014-09-21 13:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (171 votes), past polls