Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 717
goodsamaritan Avatar asked Feb 01 '26 02:02

goodsamaritan


1 Answers

here my solution

Observable
   .just(items)
   .map({ (items) -> [AnyObject] in
       return items.sorted(by: { (item1, item2) -> Bool in
          return item1.name < item2.name
       })
   })
   ....
like image 137
douarbou Avatar answered Feb 03 '26 04:02

douarbou