Sorting in is Realmpretty simple.
Here is an example:
Suppose you want to sort your contact list by name, you must sort it when you request results, you will get results already sorted for you.
There are several ways to achieve this.
Example:
1) A simple and recommended way:
RealmResults<Contacts> result = realm.where(Contacts.class).findAllSorted("name");
RealmResults<Contacts> result = realm.where(Contacts.class).findAllSorted("name", Sort.DESCENDING);
2)
, .
RealmResults<Contacts> result = realm.where(Contacts.class).findAll();
result = result.sort("name"); // for sorting ascending
// and if you want to sort in descending order
result = result.sort("name", Sort.DESCENDING);
, Realm , .
,