goodsamaritan goodsamaritan - 5 months ago 154
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

I figured

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

Feels good!