logo       

Re: Collection sorting: msg#00189

lang.groovy.user

Subject: 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/




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise