jastrachan | 29 Nov 15:34 2004
Picon

Re: Collection sorting


On 29 Nov 2004, at 12:41, Babelex wrote:

> Excellent thanks James
>
> I had to use : sortedKeys = keys.sort(){a,b | return a <=> b}
> if i just used keys.sort(){a,b | return a <=> b} and then iterated
> through keys it wasnt sorted (keys is the result of a map.keySet() ) ,
> which indicates it doesnt sort the original collection but returns a
> collection of sorted objects , is that correct?

Yes.

To sort the keys of a map you need to use a SortedMap.

James
-------
http://radio.weblogs.com/0112098/


Gmane