compare_ranks function

Count occurrences of pairs in rankings