I\'m writing an app in Swift 2.2 targeting iOS 8 and using Realm. I allow the user to sort objects based on various optional properties using Results.sorted(_:ascendin
Realm doesn't support custom sorting of Results other than what the Results.sorted(_:ascending:) method gives you. But you can compose this yourself fairly easily by concatenating two queries, maybe even exposing that through a computed property:
var results: [MyModel] {
let sorted = realm.objects(MyModel).sorted("...", ascending: true)
return sorted.filter("optionalProperty != nil") +
sorted.filter("optionalProperty == nil")
}