Excel Sort Function

Learn how to use the Excel SORT function to sort your data lists, ranges, and arrays.

6 minute read


Use this formula to sort a range of data (also known as a list or array of data).

The SORT formula is perfect for users looking to reorganize their data sets in a logical, easy-to-follow manner. Some common sort types include alphabetical sort (A-Z) or chronological sort (oldest to newest).

Function Layout (Syntax):

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

Inputs (Arguments):

  • Array: The base set of cells to sort.
  • [Sort_index]: Column index number. The sort function allows users to indicate which column to sort by (the first column from the left is 1, the second column from the left is 2, etc.). Default option is to sort by the first column from the left.
  • [Sort_order]: Ascending or descending order. Ascending order (A-Z or Oldest to Newest) is represented by a 1 and descending order (Z-A or Newest to Oldest) is represented by a -1. Default option is to sort by ascending order.
  • [By_col]: Sort by column instead of row. If you input “TRUE” you can switch the function to sort by column while the input “FALSE” sorts the range by rows. The default option is to sort by rows.

Example: Simple Sort

Let’s start with a basic example where we’ll sort a table with customer purchase data.

Example Excel Sort Data List
Example Excel Data List

In this particular example, we have a table containing the purchase date, customer name, and purchase amount. Let’s sort the table by purchase date from oldest to newest by following these steps:

  1. Initiate the formula by typing “=SORT(“.
  2. Fill in the array input. This should be cells B3:D11.
  3. Ignore the other optional inputs and close the function. You should see a table sorted from oldest purchase dates to newest purchase dates.
Excel Simple Sort Example
Excel Simple Sort

Notice how we only input the array argument and ignore all of the other optional inputs. This tells the function to use the default settings for the other optional inputs (sort by first column, sort by ascending order, and sort by rows).

Example: Sorting Second Column

Now let’s try another example where this time we’ll use the optional input [sort_index]. This optional input allows you to tell Excel which column you want to sort by. If you want to sort by the first column from the left type 1, for the second column type 2, third column type 3 … and so on and so forth.

In this particular example, we’ll sort the table by the second column instead of the first column. To do this, simply set [sort_index] = 2.

Excel Sort By Second Column
Sorting by Second Column

Example: Ascending vs Descending Order

Now let’s continue the previous example by adding on another optional input, [sort_order]. Sort order allows you to tell Excel to sort by ascending or descending order.

In this particular example, we’ll change the default sort and use descending order by typing in -1.

Excel Descending Sort Example
Sort by Descending Order

By using this sort function, we have essentially told Excel to sort the customer names (second column) by descending order (Z-A).

Example: Sorting by Column

Now let’s take a look at a different example where we’ll sort by column.

Excel Sort Column Data
Excel Column Data

In this case, we have 3 columns of sales data. Here, we’ll use the sort function to sort the columns chronologically so that we have January first, followed by February, then March.

To do this, we’ll skip the other optional inputs and simply enter “TRUE” for the [by_col] input.

Excel Sort By Column
Excel Sort By Column

Example: Sort + Filter Function

The SORT function is commonly combined with the FILTER function when users want to filter a dataset and sort the dataset in one step.

Let’s take a look at how this works by revisiting our first example. Let’s say in this particular instance, we’ll want to sort for purchases greater than $90 then sort those purchases from greatest to smallest.

Step 1 

Step 1 is to first implement the filter function. This can be done by selecting the initial data range and setting the filter criteria where the purchase amount (column D) is greater than $90.

Excel Filter Function
Excel Filter Function

Step 2

Now that you have the filtered list in place, you can wrap the SORT function around the FILTER function to start your sort. In this case, we want to sort by purchase amount (3rd column) in descending order (represented by -1).

Sort and Filter Function
Filter Function Nested In Sort Function

Additional Resources:

If you’re interested in further developing your Excel skills to better your chances of landing a competitive business or finance role, check out our Excel for Business & Finance Course and more using the get started button below.

Other Articles You May Find Helpful:


Building a cash flow statement from scratch using a company income statement and balance sheet is one of the most fundamental finance exercises commonly used to test interns and full-time professionals at elite level finance firms.

Test hyperlink

Image caption goes here
Sample Image Insertion
Dolor enim eu tortor urna sed duis nulla. Aliquam vestibulum, nulla odio nisl vitae. In aliquet pellentesque aenean hac vestibulum turpis mi bibendum diam. Tempor integer aliquam in vitae malesuada fringilla.

Elit nisi in eleifend sed nisi. Pulvinar at orci, proin imperdiet commodo consectetur convallis risus. Sed condimentum enim dignissim adipiscing faucibus consequat, urna. Viverra purus et erat auctor aliquam. Risus, volutpat vulputate posuere purus sit congue convallis aliquet. Arcu id augue ut feugiat donec porttitor neque. Mauris, neque ultricies eu vestibulum, bibendum quam lorem id. Dolor lacus, eget nunc lectus in tellus, pharetra, porttitor.

  • Test Bullet List 1
  • Test Bullet List 2
  • Test Bullet List 3
"Ipsum sit mattis nulla quam nulla. Gravida id gravida ac enim mauris id. Non pellentesque congue eget consectetur turpis. Sapien, dictum molestie sem tempor. Diam elit, orci, tincidunt aenean tempus."

Tristique odio senectus nam posuere ornare leo metus, ultricies. Blandit duis ultricies vulputate morbi feugiat cras placerat elit. Aliquam tellus lorem sed ac. Montes, sed mattis pellentesque suscipit accumsan. Cursus viverra aenean magna risus elementum faucibus molestie pellentesque. Arcu ultricies sed mauris vestibulum.


Morbi sed imperdiet in ipsum, adipiscing elit dui lectus. Tellus id scelerisque est ultricies ultricies. Duis est sit sed leo nisl, blandit elit sagittis. Quisque tristique consequat quam sed. Nisl at scelerisque amet nulla purus habitasse.

Nunc sed faucibus bibendum feugiat sed interdum. Ipsum egestas condimentum mi massa. In tincidunt pharetra consectetur sed duis facilisis metus. Etiam egestas in nec sed et. Quis lobortis at sit dictum eget nibh tortor commodo cursus.

Odio felis sagittis, morbi feugiat tortor vitae feugiat fusce aliquet. Nam elementum urna nisi aliquet erat dolor enim. Ornare id morbi eget ipsum. Aliquam senectus neque ut id eget consectetur dictum. Donec posuere pharetra odio consequat scelerisque et, nunc tortor.
Nulla adipiscing erat a erat. Condimentum lorem posuere gravida enim posuere cursus diam.

Michael Quach
Michael Quach
Senior Instructor

Ready to Level Up Your Career?

Learn the practical skills used at Fortune 500 companies across the globe.