Each possible complete ranking of the candidates is given a "distance" score. For each pair of candidates, find the number of ballots that order them the the opposite way as the given ranking. The distance is the sum across all such pairs. The ranking with the least distance wins.
Most text of this article is derived with permission from Electoral Methods: Single Winner.