Reputation: 6972
I have around 20 rows in RealmResults and need to sort the list with recent dates
RealmConfiguration realmConfig = new RealmConfiguration.Builder(getActivity()).build();
Realm realm = Realm.getInstance(realmConfig);
Like below
RealmResults<MyTable> List = realm.where(MyTable.class).findAll().sort("date",SORT.DESCENDING);
Upvotes: 12
Views: 13902
Reputation: 81588
It's really just the following.
RealmResults<MyTable> list = realm.where(MyTable.class)
.findAllSorted("date",Sort.DESCENDING);
And since 4.3.x:
RealmResults<MyTable> list = realm.where(MyTable.class)
.sort("date",Sort.DESCENDING)
.findAll();
Upvotes: 33
Reputation: 71
realmResults.sort("Date", true);
Works with the Version io.realm:realm-android:0.82.1
Upvotes: 4