How can you Sort a stream by timestamp in Reactivex?

廉价感情. 提交于 2021-02-11 13:37:15

问题


I've combined streams from firestore and now I need to sort them by timestamp (descending) . I really don't know much about reactiveX ...I'm using dartRx. I seen a few solutions using a comparator but not really sure how to use it.

Class Order{
Timestamp timestamp;
}

Stream<List<Order>> sortByTimestamp(){
return combineList(order).....//my stream
}

回答1:


thanks for your question. Here is my way :)

return combineList(order).map((orders) => orders.sort(comparator).toList());


来源:https://stackoverflow.com/questions/62986854/how-can-you-sort-a-stream-by-timestamp-in-reactivex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!