Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.7.1
-
None
-
None
Description
The following code example should work:
class Person { String first, last int compareTo(Object other) { other.first <=> first } } def people = [ new Person(first:'Alex', last:'Smith'), new Person(first:'Zak', last:'Smith') ] def comparablePeople = people.collect{ it as Comparable } Collections.sort(comparablePeople) assert comparablePeople*.first == ['Zak', 'Alex']