There are some scenarios where you would like to sort the emissions. The sorted operator helps you do that. It will internally collect and reemit all the emissions from the source producer after sorting.
Let's take a look at this example and try to understand this operator better:
fun main(args: Array<String>) { println("default with integer") listOf(2,6,7,1,3,4,5,8,10,9) .toObservable() .sorted()//(1) .subscribe { println("Received $it") } println("default with String") listOf("alpha","gamma","beta","theta") .toObservable() .sorted()//(2) .subscribe { println("Received $it") } println("custom sortFunction with integer") listOf(2,6,7,1,3,4,5,8,10,9) .toObservable() .sorted { item1, item2 -> if(item1>item2) ...