我无法按顺序排列对象列表
让我们说这是我的Class Thing
class Thing {
Profil profil
String status = 'ready'
Date dtCreated = new Date()
}
在我创建列表的东西的方法里面
List profiles = profil.xyz?.collect { Profil.collection.findOne(_id:it) }
List things = []
然后我填充每个配置文件的每个相关联的列表
profiles.each() { profile,i ->
if(profile) {
things += Thing.findAllByProfilAndStatus(profile, "ready", [sort: 'dtCreated', order: 'desc']) as
}
好的,现在事情有很多东西,不幸的是,[order:’desc’]被应用于每一组事物,我需要通过dtCreated对整个列表进行排序,这样可以像奇怪的
things.sort{it.dtCreated}
好的,现在所有的东西都按日期排序,但顺序错误,最新的事情是列表中的最后一件事
所以我需要排在相反的方向,我没有找到任何东西在网络上,让我前进,尝试的东西,像
things.sort{-it.dtCreated} //doesnt work
things.sort{it.dtCreated}.reverse() //has no effect
我没有找到任何这样的标准操作的groovy方法,也许有人有一个提示,我可以按日期排序我的事情按顺序吗?必须有一些像我上面使用的orm [sort:’dtCreated’,order:’desc’]
还是不行?
任何提示感谢提前