Sorting in Grails is easy, but defining the sort order of 'hasMany' children of an object is not obvious...

Just a simple example how it works:

The SsmNote class has an attribute "created" which is use to sort the elements when ssmElementInstance.notes is called.

 

class SsmElement {
    String name
    static hasMany = [notes:SsmNote]


    static mapping = {
        sort 'name'
        notes sort:'created', order:'desc'
    }
}
class SsmNote {
    Date created
    String note
    static belongsTo = [element:SsmElement]
}