swift - Remove item without swap in Realm -


if use code:

try! self.realm.write {                      let deletedobject = self.storage_array[lbl.tag]                     self.realm.delete(deletedobject)                      self.reload()                     } 

where

let realm = try! realm()     lazy var storage_array: results<storage> = { self.realm.objects(storage) }() 

the item removed @ place last item appeared. is, before: 1,2,3,4, (remove 2) after: 1,4,3

how can remove item without changing arrangement? is, want: 1,3,4.

objects in realm have no inherent order. if you'd objects in results in specific order should sort them explicitly using results.sorted(_:ascending:).


Comments