Hi Veronique,
you have to use the constructor TreeMap(Comparator c) contructor and
provide a comparator implementation which sorts the key in the right order.
Thomas
P.S. :A small hint: as this is not a torque-related question, you are lucky
to get this question answered here.
Veronique Couderc <[EMAIL PROTECTED]> schrieb am 16.07.2004
18:25:20:
>
> Hi,
>
> Do you know how to use SortedMap in a descending order?
>
>
> This prints the elements in ascending order:
>
> SortedMap sortedMap = new TreeMap();
> sortedMap.putAll(ht);
> Iterator iter = sortedMap.keySet().iterator();
> while (iter.hasNext())
> {
> String key = (String)iter.next();
> out.println(sortedMap.get(key));
>
> }//end while
>
>
> I found this on the net but can't make it work:
>
> Creates a reversed version of this map.
> Must be <code>O(n)</code>, where <code>n</code> is the number of
> elements in this collection.
> @return A map with the elements in reverse order.
> public abstract SortedMap reversed();
>
> Many thanks
> vero
>
>
>
>
> --
> Regards
>
> Veronique Couderc
> SensoryNet Ltd, London
>
> t. 0845 226 3012
> f. 0845 226 8512
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]