How can I order my Realm results using multiple properties?
I'm sorting them first using one property like this:
allShows = Show.allObjects().sortedResultsUsingProperty("dateStart", ascending: true)
But now I also want to do a secondary sort by another property "timeStart". I tried like this:
allShows = Show.allObjects().sortedResultsUsingProperty("dateStart", ascending: true).sortedResultsUsingProperty("timeStart", ascending: true)
This will just make the results sorted only by the second property. Please help.
i have found a solution.
But if you put more than one sort descripton in array like example below
this won't work. I really don't understand why.
Figured it out like this:
Updated for Swift 4 syntax
This is how to do it as of Realm 2.5
In RealmSwift we can write multiple properties like this:
If you want to use more properties,you can add values of
SortDescriptor()
to the array.