2
我有列出哪種類型Person
對象:順序列表
class Person{
int id
String name
String bestColor
}
def persons = [ new Person(1,'Abdennour','white'),
new Person(2,'Ali','red'),
new Person(3,'Hsen','white'),
new Person(4,'Aicha','green') ]
和我有顏色的列表:
def colors=['green','white','red']
我想根據第3字段訂購persons
列表(bestColor
)。但是,我不想按字母順序排列顏色,而是我想要與colors
列表相同的順序。 這意味着,該預期的結果:
def persons=[new Person(4,'Aicha','green')
,new Person(1,'Abdennour','white')
,new Person(3,'Hsen','white')
,new Person(2,'Ali','red')]
真的,謝謝! –