def sort_match_results(match_results):
    matches = {}
    for result in match_results:
        for to_pk in result.to_elems:
            if to_pk not in matches:
                matches[to_pk] = [result.to_elems[to_pk][0], 0.0]
            matches[to_pk][1] += result.to_elems[to_pk][1] * result.factor
    sorted_matches = sorted(matches.values(), key=lambda l: l[1], reverse=True)

    return sorted_matches
dataset/ETHPy150Open bartdag/recodoc2/recodoc2/apps/doc/parser/doc_diff.py/sort_match_results/original