def sort_candidate_pairs(pairs, ice_controlling):
    def pair_priority(pair):
        return -candidate_pair_priority(pair.local_candidate,
                                        pair.remote_candidate,
                                        ice_controlling)
    pairs.sort(key=pair_priority)