velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Christian <>
Subject Re: SortedMap/TreeMap in a tool does not sort
Date Tue, 05 Apr 2005 14:01:25 GMT
Hi Robert,

Remember that SortedMap/TreeMap only guarantee "that the map will be in 
ascending key order, sorted according to the natural order for the key's 
class". This is as opposed to the put order.

Looks like you need to either supply a Comparator when creating the 
TreeMap, or implement Comparable in your question classes.


- simon

Robert Koberg wrote:
> Hi,
>  From what I am seeing, it seems to be the case that velocity 
> tools/templates do not work with SortedMap/TreeMap created in the tool. 
> That is, they do not come to the template in the order they were placed 
> in the map. Is that to be expected?
> <my-case>I have a tool(s) that creates 'static final' question (and 
> answer, if multichoice) objects. These question objects are added to a 
> SortedMap. If the question object has multiple choice answers, those 
> answers are also added to their own SortedMap. The answers come back in 
> the put order, but the questions do not. (before anyone asks why I am 
> creating static final question objects in a tool (quizes), the classes 
> are generated by XSL at build time before compile)</my-case>
> best,
> -Rob
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message