Skip to main content

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 function 1


Syntax

=SORT(array, [sort_index], [sort_order], [by_col])


Arguments

  • 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.

Return Value

The SORT function returns an array.


Function Notes

  • 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.

Example

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:

=SORT(B3:E14,4,-1)

sort function 2


Related functions

Excel SORTBY Function

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.

Excel UNIQUE Function

The UNIQUE function extracts unique values from a range of data. The data can include text, numbers, dates, error values, etc.

Excel FILTER Function

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

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates  |  Delete Blank Rows  |  Combine Columns or Cells without Losing Data  |  Round without Formula ...
Super VLookup: Multiple Criteria  |  Multiple Value  |  Across Multi-Sheets  |  Fuzzy Lookup...
Adv. Drop-down List: Easy Drop Down List  |  Dependent Drop Down List  |  Multi-select Drop Down List...
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  Compare Columns to Select Same & Different Cells ...
Featured Features: Grid Focus  |  Design View  |  Big Formula Bar  |  Workbook & Sheet Manager | Resource Library (Auto Text)  |  Date Picker  |  Combine Worksheets  |  Encrypt/Decrypt Cells  |  Send Emails by List  |  Super Filter  |  Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters ...)  |  50+ Chart Types (Gantt Chart ...)  |  40+ Practical Formulas (Calculate age based on birthday ...)  |  19 Insertion Tools (Insert QR Code, Insert Picture from Path ...)  |  12 Conversion Tools (Numbers to Words, Currency Conversion ...)  |  7 Merge & Split Tools (Advanced Combine Rows, Split Excel Cells ...)  |  ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

Description


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, Edge and Firefox.
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations