goodsamaritan goodsamaritan - 1 year ago 478
Swift Question

RxSwift Observable Array Sorting

I am trying to sort an observable array and havent had any luck (RxSwift n00b)

let items = [AnyObject]?
let locations = Observable.just(items)


I want to achieve something like this on locations

items.sortInPlace({$0.name < $1.name})


Any pointers will be appreciated!

Answer Source

I figured

  1. initing locations as Variable([AnyObject]())
  2. setting locations asObservable
  3. sorting as locations.value.sortInPlace({$0.name < $1.name})

Feels good!