On Mon, May 6, 2013 at 2:30 PM, Sergiu Dumitriu wrote:

> On 05/06/2013 03:15 PM, Travis P wrote (with minor fix):
> > Via web searching, I've found quite a few people reversing lists by
> writing
> > out loops.
> >
> > Seems to me, we should be able to something like:
> >
> > #set ($lst = ["a","b","c"])
> > #set ($revlst = $lst.clone() )
> > $Collection.reverse($revlst)
> > ... <snip> ...
>
> You should use the existing SortTool tool.
>
>
> http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/SortTool.html
>
> For security reasons, Velocity doesn't allow accessing raw classes or
> instantiating new objects. You must always start from a valid variable
> placed in the context.
>
> See http://velocity.apache.org/tools/releases/2.0/ for more details
> about tools and how to configure them.
>

Thanks Sergiu.

I have written my own Tools.  I was just wondering if I could use the VTL
for more rather than diving down into my own tools for such basic stuff
(and given that I found several other folks also asking this question, I'm
not alone in that desire).

I don't think the sort tool can be used for this, unless the list elements
have a property which is the their own index (and I don't see that).  I
don't want to sort based on object values.  I want to reverse the order of
a list, independent of what any values may be.

-Travis

Reply via email to