Is there a way to sort a list by a binary comparator in kotlin?
I would like to sort a list of pairs according to their ratio with a lambda binary comparator to avoid precision errors, but so far I only know the sortBy or sortWith function which only takes one single object for sorting. In c++ I would write:
std::sort(v.begin(), v.end(), [](std::pair a, std::pair b) {
return a.first * b.second < a.second * b.first;
}
Is there equivalent kotlin code for that? Thanks.