使用 Comparator 和 SortedSet
Comparator cmp = [ compare:{ a, b -> a <=> b } ] as Comparator
def col = [ 'aa', 'aa', 'nn', '00' ]
SortedSet sorted = new TreeSet( cmp )
sorted.addAll col
assert '[00, aa, nn]' == sorted.toString()
Comparator cmp = [ compare:{ a, b -> a <=> b } ] as Comparator
def col = [ 'aa', 'aa', 'nn', '00' ]
SortedSet sorted = new TreeSet( cmp )
sorted.addAll col
assert '[00, aa, nn]' == sorted.toString()