You can sort objects using queries arguments such as those found in the
list method:
def airports = Airport.list(sort:'name')
However, you can also declare the sort order declaratively:
class Airport {
…
static mapping = {
sort "name"
}
}
You can also configure the sort order if necessary:
class Airport {
…
static mapping = {
sort name:"desc"
}
}
Alternatively, you can configure sort order at the association level:
class Airport {
…
static hasMany = [flights:Flight]
static mapping = {
flights sort:'number'
}
}