Cellgrids Cellgridsby LearnWithRinkesh
Home › Excel tutorials › SORT Function in Excel (Sort Data with a Formula)

How to Use the SORT Function in Excel to Sort Data Automatically

By Rinkesh Shah · Business Analyst, 8 years in data · Updated 2026-10-31

▶ Video coming soon

The SORT function sorts a range and returns the result in a new place, so your original data stays untouched. When someone adds a row, the sorted list updates by itself. This is the big difference from the Sort button on the ribbon.

Syntax

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

Sort a table by sales, highest first

With a table in A2:C100 and sales in column 3:

=SORT(A2:C100, 3, -1)

The whole table spills out with the biggest sale at the top.

Top 5 only

Combine SORT with TAKE (Microsoft 365) to show only the top rows:

=TAKE(SORT(A2:C100,3,-1),5)

In older versions use INDEX with SEQUENCE, or the LARGE function.

Sort by more than one column

Use SORTBY. This example sorts by region A to Z, then by sales high to low:

=SORTBY(A2:C100, A2:A100, 1, C2:C100, -1)

Sort and remove duplicates together

=SORT(UNIQUE(A2:A500))

This gives an alphabetical drop-down source list that updates itself.

Common mistakes

Worked example

=SORT(A2:C100,3,-1) sorts the table by column 3 from largest to smallest. =SORT(A2:C100,2,1) sorts by column 2 A to Z. Combine: =SORT(UNIQUE(A2:A100)).

Common mistakes

Frequently asked questions

Does SORT change the original data?

No, it makes a sorted copy that updates when the data changes.

Sort by two columns?

=SORT(A2:C100,{2,3},{1,-1}).

SORT or the Sort button?

The button changes the data. SORT leaves it untouched.

Practice this online, free

Reading is only half of learning Excel. Cellgrids is a free place for online Excel practice: solve Excel formula exercises in a live spreadsheet, prepare for Excel interview questions, and work through business case studies built for data analytics and business analytics roles.

Practice these formulas: SORT, UNIQUE, LARGE.

Start Excel practice → Case studies