sorting - sort a list of @Sortable objects in descending order -
i have class
@sortable(includes = ['date']) class item { // other fields not relevant question date date }
if sort list
of these objects sort them in ascending order based on date
field. there way sort them in descending order instead? know call reverse()
on result of ascending sort, seems bit inefficient
here couple of ways:
def items = [ new item(date: new date(40000)), new item(date: new date(1000)), new item(date: new date(200000)), new item(date: new date(00100)), ] items.sort { a, b -> b <=> } items.sort(true, collections.reverseorder())
Comments
Post a Comment