Josh,

I wondered why items.sort wasn't working, until I spotted
another syntax error.  Thanks for making me look again.

--Jon


----- Original Message ----- 
From: "Josh Rosenbaum" <[EMAIL PROTECTED]>
To: "Jonathan Mangin" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Thursday, May 31, 2007 12:41 PM
Subject: Re: [Templates] Sorting a hash by value


> Jonathan Mangin wrote:
> > Hi,
> >
> > I have a simple hash with numeric id as key and
> > alphabetic name as value.  In my template:
> >
> > [% FOREACH key IN items.keys %]
> >    [% IF key == rows.0.1 %]
> >       <option value=[% key %] selected>[% items.$key %]
> >    [% ELSE %]
> >       <option value=[% key %]>[% items.$key %]
> >    [% END %]
> > [% END %]
> >
> > %items is populating up to 20 drop-downs and I'd like to
> > sort on value.  Is there a way to do that?
> >
> > Thanks,
> > Jon
>
>
http://www.template-toolkit.org/docs/plain/Manual/VMethods.html#Hash_Virtual_Methods
>
> See the sort/nsort vmethods for hashes. I think that'll do what you want.
>
> -- Josh


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to