RxSwift可观察的数组排序

问题描述:

我想排序可观察到的数组,还没有任何运气(RxSwift的n00b)RxSwift可观察的数组排序

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

我想实现像这样的位置

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

任何指针会不胜感激!

我想通

  1. INITING位置为Variable([AnyObject]())
  2. 设置位置asObservable
  3. 排序为locations.value.sortInPlace({$0.name < $1.name})

感觉还不错!

这里我的解决方案

Observable 
    .just(items) 
    .map({ (items) -> [AnyObject] in 
     return items.sorted(by: { (item1, item2) -> Bool in 
      return item1.name < item2.name 
     }) 
    }) 
    ....