Excel SORT Function
The SORT function sorts the contents of a range or array in ascending or descending order.
Note: The SORT function is only available in Excel for Microsoft 365, Excel 2021 or newer versions of Excel, and Excel for the web.
=SORT(array, [sort_index], [sort_order], [by_col])
- array (required): The range or array to sort.
- [sort_index] (optional): A number indicating the row or column to sort by. Default is 1.
- [sort_order] (optional): A number indicating the sort order:
- 1 or omitted, to sort in ascending order;
- -1, to sort in descending order.
- [by_col] (optional): A logical value indicating the direction of sorting:
- TRUE, to sort by column;
- FALSE or omitted, to sort by row.
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:
The SORTBY function sorts the contents of one range or array based on the values in a corresponding range or array, no matter the corresponding range or array is included in the range or array to be sorted or not.
The UNIQUE function extracts unique values from a range of data. The data can include text, numbers, dates, error values, etc.
The FILTER function filters a range of data and dynamically returns the matching results according to the criteria you specify.
The Best Office Productivity Tools
Kutools for Excel - Helps You To Stand Out From Crowd
Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.
- Designed for 1500 work scenarios, helps you solve 80% Excel problems.
- Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
- Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
- 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)
- One second to switch between dozens of open documents!
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Increases your productivity by 50% when viewing and editing multiple documents.
- Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.