Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^4: Sorting Template Toolkit Array of Hashrefs

by roho (Canon)
on Jul 19, 2012 at 10:35 UTC ( #982609=note: print w/replies, xml ) Need Help??


in reply to Re^3: 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?

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

  • Comment on Re^4: Sorting Template Toolkit Array of Hashrefs

Replies are listed 'Best First'.
Re^5: Sorting Template Toolkit Array of Hashrefs
by Anonymous Monk on Jul 21, 2012 at 10:49 UTC

    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" )

      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://982609]
help
Chatterbox?
[LanX]: I remeber M::S (it was dialog driven?) to be buggy
[stevieb]: As far as Dist::Zilla goes, I don't like installing that other than on systems my test platorm runs on. I find it too heavy. I prefer being able to glean a Makefile.PL
[LanX]: what's frustrating me is that a distribution has lots of dupplicated info
[stevieb]: LanX I don't know if it's dialog driven; I just use it in the simplest of terms (just run module-starter at the CLI, and the very last couple of lines are how I use it.
[stevieb]: which dist are you speaking of regarding dups, LanX?
[LanX]: readme version number and so on ...
[stevieb]: with M::S, you can also add other tags, but defaults work... such as --license=perl --eumm
[LanX]: I'm not a big fan of pure make, apparently the auto generated ones are so complicated to be able to work with all possible makes

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2017-08-18 20:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (310 votes). Check out past polls.

    Notices?