我有这样的方法:
override fun getStuff(): MutableList<Stuff> = realm.where(Stuff::class.java)
.findAllSorted("timeStamp", Sort.DESCENDING)
.distinct("otherId")
其中Stuff
的内容有timeStamp
个。{
如果我这样做:
storage.saveStuff(Stuff("a", otherId=1, timeStamp=1))
storage.saveStuff(Stuff("b", otherId=1, timeStamp=2))
storage.saveStuff(Stuff("c", otherId=1, timeStamp=3))
// Other stuff with different otherId
我期待:
storage.getStuff()[0].name == "c"
但事实并非如此。它a
如果我设置Sort.ASCENDING
,我仍会获得a
。
我做错了什么?