def list =[10,3,2,12,19,40,30]


升序:

list.sort {a,b ->

 return a.compareTo(b)

}


降序:

list.sort {a,b ->

 return b.compareTo(a)

}