【发布时间】:2010-10-18 06:09:56
【问题描述】:
如何在 Groovy 中按字符串长度顺序对 String 中的 ArrayList 进行排序?
代码:
def words = ['groovy', 'is', 'cool']
// your code goes here:
// code that sorts words in ascending length-of-word order
assert words == ['is', 'cool', 'groovy']
肯定有不止一种方法可以做到这一点 - 所以我会将答案授予提供最优雅解决方案的人。
【问题讨论】:
标签: string sorting groovy arraylist