|
Collection sorting: msg#00186lang.groovy.user
Hi all Just browsing through the groovy reference summary i notice the collection.sort(){..} closure support. Obviously on the sheet it doesnt actually show one how it operates except to indicate the closure acts as a comparator, I just need to work out how to use this can anyone give me an example, i was thinking this kind of thing : myCollectionOfNumbers.sort() {key | return it < key ? -1 : (it == key ? 0 : 1)} to sort a collection of integers I may be well of base here not being a groovy expert, my actual problem is also more complex it's a collection of stings that i wish to arrange alphabetically or numerically (even though some arent real numbers) Anyone care to touch me with a clue stick .. -- regards babelex #OpenSource means free to innovate#
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Groovy Support in IntelliJ IDEA, Arik Kfir |
|---|---|
| Next by Date: | Re: Collection sorting, jastrachan-ee4meeAH724 |
| Previous by Thread: | Groovy Support in IntelliJ IDEA, Guillaume Laforge |
| Next by Thread: | Re: Collection sorting, jastrachan-ee4meeAH724 |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |