ArrayList(originalItems).sortedWith(Comparator { b, a -> compareValuesBy(a, b, { it.localHits }, { it.title }) })
Or you can define this function:
fun <T> compareByDescending(vararg selectors: (T) -> Comparable<*>?): Comparator<T> { return Comparator { b, a -> compareValuesBy(a, b, *selectors) } }
and use it as follows:
ArrayList(originalItems).sortedWith(compareByDescending({ it.localHits }, { it.title }))
source share