I faced an interesting scenario: Splitting a strea...
# stdlib
v
I faced an interesting scenario: Splitting a stream into two, working with them separately, and then zipping them in the initial order For now I do:
Copy code
val (As, Bs) = list.mapIndexed { i, it -> Pair(it, i) }.partition { condition(it) }
    
  val Cs = As. map {..}.filter{..}.sortBy{..}

  return (As + Cs).sortedBy {it.second}.map {it.first}
I want a way to generalise it somehow