By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
Reading: SORT vs. SORTBY in Microsoft Excel: Which Should You Use?
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
World of Software > News > SORT vs. SORTBY in Microsoft Excel: Which Should You Use?
News

SORT vs. SORTBY in Microsoft Excel: Which Should You Use?

News Room
Last updated: 2025/08/25 at 5:48 PM
News Room Published 25 August 2025
Share
SHARE

The SORT and SORTBY functions let you extract certain columns and rows from a dataset and sort them in a certain order, all while preserving the source data. Even though they work in similar ways, there are key differences you should be aware of if you’re deciding which one to use.

In all the examples in this guide, the source data is formatted as an Excel table. This is because both the SORT and SORTBY functions work best when the source data is structured in this way. As a result, all formulas use structured references. To apply the same principles in regular ranges, use direct cell references instead.

The SORT and SORTBY Syntaxes

Before I go into the different behaviors of the SORT and SORTBY functions in Excel, here’s a quick overview of their syntaxes and a straightforward example of each in use.

Microsoft Excel’s SORT function has four arguments—one required and three optional:

=SORT(a,b,c,d)

where

  • a (required) is the array (a whole table or part of a table) containing the columns or rows you want to sort,
  • b (optional) is an index number indicating which column or row to sort by,
  • c (optional) is a number determining the sort order (1 = ascending; -1 = descending), and
  • d (optional) is a Boolean value indicating the sort direction (FALSE = sort vertically by row; TRUE = sort horizontally by column).

If argument b is omitted, the first row or column is returned. If argument c is omitted, Excel defers to an ascending order. If argument d is omitted, the data is sorted vertically by row.

If you find yourself needing to sort your data horizontally, rather than using argument d, consider transposing your data so that the rows become columns and the columns become rows.

In this example, typing:

=SORT(T_Scores,5,-1)

extracts and sorts the whole T_Scores table by the Total column (5) in descending order (-1).

Whether you’re using the SORT or SORTBY function, to avoid the table’s column headers being considered data rows in the sorting process, make sure that argument a only includes the rows beneath the header row. Then, duplicate the column headers directly above the result by typing them manually or using a formula, such as:

=T_Scores[#Headers]

On the other hand, the SORTBY function has two mandatory arguments, and the number of optional arguments you use depends on the number of rows or columns by which you want to sort the data:

=SORTBY(a,b¹,b²,c¹,c²...)

where

  • a (required) is the array (a whole table or part of a table) containing the columns or rows you want to sort,
  • b¹ (required) is the first array to sort by,
  • b² (optional) is a number determining the sort order of the first sort array (1 = ascending; -1 = descending),
  • c¹ (optional) is the second array to sort by, and
  • c² (optional) is the second sort order number.

In other words, b¹ and b² are the first array-order pairing, c¹ and c² are the second array-order pairing, and the maximum number of these pairings is determined by the number of rows or columns in the dataset you want to sort.

If you only have one sort-by argument (b¹), you can omit the sort-order argument (b²), and the result will default to an ascending order. However, if you have more than one sort-by argument, they must all be accompanied by a sort-order argument.

The whole array and sort-by arrays must contain the same number of rows if you’re sorting the data vertically, or the same number of columns if you’re sorting the data horizontally.

For example, typing:

=SORTBY(T_Scores,T_Scores[Total],-1)

extracts and sorts the whole T_Scores table by the Total column (T_Scores[Total]) in descending order (-1).

The SORTBY function being used to sort the T_Scores table by the Total column in descending order.

Compatibility With Different Versions of Excel

On Windows and Mac, both the SORT and SORTBY functions are supported in standalone versions of Excel released in 2021 or later and Excel for Microsoft 365. You can also use these functions in Excel for the web, the free online version of the program. Alternatively, the SORT and SORTBY functions are available to those using the Excel mobile and tablet apps or the Microsoft 365 Copilot mobile app.

Identifying the Sort-By Array

I often prefer using the SORTBY function because it’s more reliable than the SORT function when columns are added to or removed from the source data.

Here, after extracting the T_Scores table and sorting it by the Total column in descending order using the SORTBY function, I inserted a column in the source dataset. Because the SORTBY function identifies the sort-by column by a selected array or column name, the result is still sorted by the Total column.

The SORTBY function in Excel extracts and sorts the data by the Total column, even when an extra column is inserted.

However, if I insert a column in the source data after using the SORT function, the index number in the sort-by argument doesn’t recognize the change to the structure of the source dataset. In other words, the Total column is now column 5, but the formula still references column 4. As a result, I either need to update the formula manually or find a way to automate this process.

The SORT function in Excel sorts the fourth column based on the index number in the formula, showing that it does not adapt to horizontal structural changes.

So, if you envisage your data changing shape, the SORTBY function will be the better option in the long run.

Extracting and Sorting a Single Column

The most basic use of the SORT and SORTBY functions is to extract and sort a single array from a dataset.

Suppose you want to extract and sort alphabetically the teams from this T_PL table, which is currently sorted by the Capacity column from largest to smallest.

An Excel table with Premier League teams in column A, and stadium capacities in column B.

To do this using the SORT function, you need to type:

=SORT(T_PL[Team])

Because this function automatically sorts the data by the first column in ascending (alphabetical) order if only the first argument is given, the formula is nice and short.

The SORT function being used in Excel to extract a list of Premier League teams from column A, and sort the result in alphabetical order.

On the other hand, to do the same using the SORTBY function, you need to type:

=SORTBY(T_PL[Team],T_PL[Team])

since this function requires you to input both an array and a sort-by array.

The SORTBY function being used in Excel to extract a list of Premier League teams from column A, and sort the result in alphabetical order.

Thus, the SORT function is much more efficient than the SORTBY function when extracting and sorting a single array from a dataset, especially if you want the result to be in ascending order.

Extracting and Sorting Data by Multiple Levels

One of the biggest differences between the SORT and SORTBY functions is the method you need to use to extract and sort your data by more than one variable.

In this example, let’s say you want to extract and sort the T_Scores table by the Total column, and where two values in this column are the same (in this case, Tom’s and Dave’s totals), you want to sort the data alphabetically by the players’ names.

A table in Excel with the Total column labeled '1,' and the Name column labeled '2.'

To achieve this using the SORTBY function, whose syntax is specifically designed to cater for multilevel sorting, you should type the following formula:

=SORTBY(T_Scores,T_Scores[Total],-1,T_Scores[Name],1)

where

  • T_Scores is the name of the table you want to extract and sort,
  • T_Scores[Total],-1 as the first sort-by-sort-order pairing tells Excel that the primary column by which you want to sort the array is the Total column, in descending order, and
  • T_Scores[Name],1 as the second sort-by-sort-order pairing tells Excel that the secondary column by which you want to sort the array is the Name column, in ascending (alphabetical) order.

A table in Excel is sorted primarily by the Total column and secondarily by the Name column, using the SORTBY function.

Notice how the extracted data is sorted by the Total column, and Dave and Tom—whose totals are the same—are sorted alphabetically.

On the other hand, if you try to achieve the same outcome using the SORT function, you’ll hit a hurdle, since—on face value—it only allows you to input one sort array and one sort-by index number. However, you can get over this hurdle by using array constants:

=SORT(T_Scores,{4,1},{-1,1})

where

  • T_Scores is the name of the table you want to extract and sort,
  • {4,1} tells Excel that you first want to sort the data by the fourth column before then sorting it by the first column, and
  • {-1,1} tells Excel that the fourth column should be in descending order, and the first column should be in ascending order.

A table in Excel is sorted primarily by the Total column and secondarily by the Name column, using the SORT function

As with the SORTBY example above, the result extracts and sorts the data by the Total column, and where any values are equal, the data is then also sorted by the Name column.

Overall, both the SORTBY and SORT functions can sort data on more than one level, and both have their advantages. If you plan to share your workbook with others, they may be more familiar with using conventional formula syntax without array constants, so using the SORTBY function would be the preferred option. On the other hand, the SORT formula containing array constants is much shorter, so if you’re looking to save time, this could be the best route.

However, as I discussed earlier, the SORTBY function is better at coping with new columns being added to the source data, as it doesn’t rely on column index numbers. As a result, this is always something to bear in mind when choosing which function to use.

Result Behavior

The beauty of both the SORT and SORTBY functions is that if the values in the source data change, they’re reflected in the sorted result. What’s more, SORT and SORTBY are dynamic array functions, meaning that if the source data is in a formatted Excel table, the result grows or shrinks if you add or delete rows.

You know that a function produces dynamic arrays when (1) the result spills from the cell where you typed the formula to adjacent cells, and (2) a temporary blue border appears when you select any cell in the result. Here, even though the SORTBY formula is typed into cell F2, the result spills from cell F2 to cell I5.

The result of a dynamic array formula in Excel is surrounded by a blue line when one of the affected cells is selected.

However, with this dynamism comes a major drawback: you can’t use the SORT and SORTBY functions within a formatted Excel table. This is because Excel tables aren’t compatible with dynamic array formulas, since both these Excel features are designed to grow and shrink automatically.

You might also face problems if the sort array argument for either function references a dataset in another Excel workbook. Specifically, dynamic array functions referencing external sources only work when both workbooks are open. So, if you close the source workbook, any linked dynamic array formulas return a #REF! error when refreshed.

Summary: Should You Use SORT or SORTBY?

Whether you use the SORT function or the SORTBY function depends on many factors, such as whether you plan to insert columns in the source dataset, the number of sort levels you want to apply, and whether you plan to share your workbook with others.

Here’s a summary of the key similarities and differences:

Property

The SORT Function

The SORTBY Function

Excel version compatibility

Excel 2016 or later, Excel for Microsoft 365, Excel for the web, Excel for mobile and tablet

Excel 2016 or later, Excel for Microsoft 365, Excel for the web, Excel for mobile and tablet

Minimum required arguments

1

2

Default sort order

Ascending

Ascending

Sort-by argument type

Index number

Selected array or table column header

Adaptability with inserted or deleted columns

Sort-by array index number doesn’t adapt to structural changes

Sort-by array stays the same

Sort direction

Vertical or horizontal

Vertical or horizontal

Extracting and sorting single arrays

Can work with a single argument

Requires at least two arguments

Extracting and sorting by multiple arrays

Requires array constants

Works natively by default

Dynamism

Produces a dynamic array

Produces a dynamic array

Table compatibility

Cannot be used in Excel tables

Cannot be used in Excel tables

Cross-workbook compatibility

Works if both workbooks are open

Works if both workbooks are open


To extract and sort non-adjacent arrays in your data, nest the CHOOSECOLS or CHOOSEROWS functions inside your SORT or SORTBY formula. Alternatively, to extract, filter, and sort columns from a dataset simultaneously, nest the FILTER function instead.

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article The Overlooked Wyatt Russell And Dennis Quaid Western Crushing It On Netflix – BGR
Next Article XRP Holds After Heavy Whale Distribution, But Is The Next Big Winner Found Somewhere Else? | HackerNoon
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

Fair and Distributed Vehicle‑Request Assignment Using Auctions and Rebalancing in Mobility‑On‑Demand | HackerNoon
Computing
Putin’s hybrid war against Europe continues to escalate
News
Nevada government offices close after massive ‘network security incident’
News
Distributed Request Assignment with Max‑Min and Deviation Fairness in On‑Demand Mobility | HackerNoon
Computing

You Might also Like

News

Putin’s hybrid war against Europe continues to escalate

7 Min Read
News

Nevada government offices close after massive ‘network security incident’

1 Min Read
News

YouTube’s Latest Experiment Is A Great Example Of How Not To Use AI – BGR

5 Min Read

Free iOS 26 Class

0 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright © All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?