Summary

To sort values by columns, you can use the SORT function. In the example shown, data is sorted by the Group column. The formula in C8 is:

=SORT(C4:L5,2,-1,TRUE)

The result is the range C4:L5 sorted by score in descending order.

Generic formula

=SORT(data,index,order,TRUE)

Explanation 

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:

=SORT(C4:L5,2,-1,TRUE)
  • 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.

With SORTBY

The SORTBY function can also be used to solve this problem. With SORTBY, the equivalent formula is:

=SORTBY(C4:L5,C5:L5,-1)
Dynamic Array Formulas are available in Office 365 only.
Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.