/**
 * Write a function that takes a list of tuples as input and sorts them based on the second element of each tuple in descending order.
 *
 * @param tuples A list of tuples, where each tuple contains two elements.
 * @return The sorted list of tuples.
 *
 * Example:
 * sortTuplesBySecondElement(listOf(1 to 5, 4 to 2, 7 to 9, 3 to 1)) // [(7, 9), (1, 5), (4, 2), (3, 1)]
 */
fun sortTuplesBySecondElement(tuples: List<Pair<Int, Int>>): List<Pair<Int, Int>> {

    return tuples.sortedByDescending { it.second }
}
/**
 * Write a function that takes a list of tuples as input and sorts them based on the second element of each tuple in descending order.
 *
 * @param tuples A list of tuples, where each tuple contains two elements.
 * @return The sorted list of tuples.
 *
 * Example:
 * sortTuplesBySecondElement(listOf(1 to 5, 4 to 2, 7 to 9, 3 to 1)) // [(7, 9), (1, 5), (4, 2), (3, 1)]
 */
fun sortTuplesBySecondElement(tuples: List<Pair<Int, Int>>): List<Pair<Int, Int>> {
/**
 * Write a function that takes a list of tuples as input and sorts them based on the second element of each tuple in descending order.
 *
 * @param tuples A list of tuples, where each tuple contains two elements.
 * @return The sorted list of tuples.
 *
 * Example:
 * sortTuplesBySecondElement(listOf(1 to 5, 4 to 2, 7 to 9, 3 to 1)) // [(7, 9), (1, 5), (4, 2), (3, 1)]
 */
fun sortTuplesBySecondElement(tuples: List<Pair<Int, Int>>): List<Pair<Int, Int>> {

    return tuples.sortedByDescending { it.second }
}