Excel SORT Function
The SORT function sorts the contents of a range or array in ascending or descending order.
The SORT function returns an array.
- array can be supplied as a row of values, a column of values, or a combination of rows and columns of values.
- The dimensions of the returned array are the same as the array argument. If one or more cells in the spill range are not empty, the #SPILL! error will be returned.
- SORT can be used between different workbooks. However, make sure the referenced workbooks are open. Otherwise, a #REF! error will be returned if you refresh the result cell.
- The results of SORT are dynamic, meaning that they update automatically when values in the source data change. However, the results will not be updated if you add new entries to array. To fix this, you should use structured references as array argument.
- To sort an array based on a column that you don’t want to include in the sorted result, or to sort an array based on two or more columns, please use the SORTBY function.
To sort the table as shown below by students’ scores in descending order with the SORT function, you should set the sort_index argument to 4 since you want to sort by the fourth column in the table, and set sort_order to -1. You don’t have to add the by_col argument since the function defaults to sort by row. Please copy or enter the formula below in the top left cell of the result table and then press Enter to get the result: