本文介绍了使用 Java 中的 Reactive Extensions 对对象集合进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 rxjava 根据对象的一个或多个字段对对象集合进行排序?
How can I can sort a collection of objects using rxjava based on one or more fields of the objects?
public class Car { public String model; public int numberOfWheels; public String color; public int yearOfProduction; } List<Car> cars = new ArrayList<>(); cars.add(...); cars.add(...); Observable<List<Car>> getCars() { Observable.just(cars) }; Observable<List<Car>> getCarsSortedByModel() { ??? }; Observable<List<Car>> getCarsSortedByColor() { ??? }; Observable<List<Car>> getCarsSortedByModelAndColor() { ??? }; 推荐答案Observable.toSortedList 将返回 Observable:
更多推荐
使用 Java 中的 Reactive Extensions 对对象集合进行排序?
发布评论