conditional

fun <T> conditional(predicate: (T, T) -> Boolean, comparator: Comparator<T>): Comparator<T>

Returns a comparator that delegates to comparator only when predicate returns true for the pair, otherwise returns 0 (preserving order). Mirrors conditional from stream-video-js.