The SORT function sorts a range using a given index, called sort_index. Normally, this index represents a column in the source data.
However, the SORT function has an optional argument called "by_col" which allows sorting values organized in columns. To sort by column, this argument must be set to TRUE, which tells the SORT function that sort_index represents a row.
In this case, we want to sort the data by Score, which appears in the second row, so we use a sort_index of 2. The SORT function that appears in C8 is configured like this:
- array is the data in the range C4:L5
- sort_index is 2, since score is in the second row
- sort_order is -1, since we want to sort in descending order
- by_col is TRUE, since data is organized in columns
The SORT function returns the sorted array into the range C8:L9. This result is dynamic; if any scores in the source data change, the results will automatically update.
The SORTBY function can also be used to solve this problem. With SORTBY, the equivalent formula is: