I want to use a spreadsheet to take a column of rankings and turning into a pairwise matrix. Suppose I had a column like so:
| Candidate | Ranking |
|---|---|
| A | 1 |
| B | 5 |
| C | 3 |
| D | 2 |
| E | 4 |
I want to create a 5x5 matrix where each cell displays a 1 if the row candidate beats the column candidate, and a 0 otherwise, like so:

(I don't know how to make a table of more than 2 columns here, so I used an image.)
I was able to make this table by manually making the first cell of each column individually, using an if statement, and dragging down, but I'd like to make a single formula that can do the whole table at once.



