Download the example workbook
This tutorial will demonstrate how to dynamically sort multiple columns in Excel and Google Sheets.
Dynamic Sorting with SORTBY Function
The SORTBY Function produces a dynamic array of sorted data.
In this example, we use the SORTBY Function to produce a dynamic array sorted by Team and then by Player Name:
Note: The SORTBY Function is written in only cell F3. The rest of the table will populate automatically.
The sorted table is dynamic, which means that if any of the Team or Player Name values change or records or added / deleted, then the output table will automatically re-size and re-sort.
Note: The SORTBY Function is not available in Excel 2019 or earlier. Read below for sorting options available for earlier versions of Excel.
Sorting in Excel 2019 or Earlier
In Excel 2019 or earlier, you can use a formula to sort a single column, but sorting by multiple columns is more challenging.
Of course, you can always use Excel’s built-in sort tool to sort by multiple columns:
Dynamic Sorting with SORT Function in Google Sheets
The SORTBY Function is not available in Google Sheets, but its SORT Function can be used instead and is more powerful than the SORT Function in Excel. It allows us to use multiple columns to dynamically sort data ranges.
In this example, we use the Google Sheets SORT Function to take a data table and produce a dynamic array that sorts it first alphabetically by Team and then by Player Name:
The Google Sheets SORT Function sorts data by the specified column numbers in the input data and allows us to set whether the sort order is ascending or not.