Each voter ranks all candidates in order of preference.
For each pair of candidates, it is determined how many voters preferred each candidate by counting whether they were higher-ranked on the ballot. If any candidate is preferred to all other candidates, they are declared the winner.
If there is no initial winner, the winner must be determined some other way. One way is to define the 'top cycle' to mean that candidates are said to be in the 'top cycle' if each of them will beat all candidates outside the top cycle in pairwise competition but not all the candidates inside the top cycle.
Then the winner can be chosen by having an Alternate Vote (AV) election between the top cycle candidates. Or, Another way would be to choose the candidate in the top cycle who, in the pairwise contest that they do worst in, they lose by the least amount.
In an election, there are 3 'top cycle' candidatess. Considering only preferences between these candidates,
41 voters voted X 1st, Y 2nd, Z 3rd 33 voters voted Y 1st, Z 2nd, X 3rd 22 voters voted Z 1st, X 2nd, Y 3rd
In pairwise comparisons:
X: against Y = 41+22-33 = +40 (ie X won by 40 votes) against Z = 41-33-22 = -14 (ie X lost by 14 votes) Y: against X = -40 against Z = 52 Z: against X = 14 against Y = -52
So X wins, because his worst result (-14) is less bad than Y's or Z's worst results (-40 and -52 respectively).
The choice of a winner from any candidate within the top cycle is to some extent arbitrary, in the sense that there are good reasons for picking any of them.
There are good reasons to regard the Condorcet criterion, when fulfilled, as the best test of who should win: so if there is a Condorcet winner, then a system for selecting one winner ought to win it. On this view, AV is not as good as the Condorcet scheme, because there are circumstances in which it will fail to pick the Condorcet winner.