Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.7.1
-
Fix Version/s: 1.7.2, 1.8-beta-1
-
Component/s: None
-
Labels:None
-
Number of attachments :
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']