文本+日期字符串列表進行排序我有一個字符串列表,每一個都包含日期的文字是這樣的:如何在Groovy
"foo_6.7.2016"
"foo_5.10.2016"
"foo_6.30.2016"
"foo_6.23.2016"
"foo_6.2.2016"
"foo_5.22.2016"
我需要時間對它們進行排序,並得到這個:
"foo_6.30.2016"
"foo_6.23.2016"
"foo_6.7.2016"
"foo_6.2.2016"
"foo_5.22.2016"
"foo_5.10.2016"
尼斯 - 絕對比我的方法更groovy的方式 –
你的方式有好處,你只能解析日期一次 –
如果使用太空船操作員... f(b)<=> f(a)然後reverse()可以消失?假設f是在這個答案中指定的閉包。 –