Sort vs SORTBY In Excel

·Updated Apr 4, 2026·
spreadsheet-analytics-biexcelmicrosoft-excelspreadsheetsdata-file-workflowsanalytics
·

Level: intermediate · ~16 min read · Intent: commercial

Audience: data analysts, finance teams, operations teams

Prerequisites

  • intermediate spreadsheet literacy
  • comfort with formulas or pivot concepts

Key takeaways

  • SORT is best when you want to sort a range by one visible row or column position, while SORTBY is more flexible when the sort order should be driven by another range or by multiple sorting keys.
  • The most important skill is understanding how dynamic sort formulas spill results, preserve the original data, and fit into modern reporting workflows without relying on manual sort clicks.

FAQ

What is the difference between SORT and SORTBY in Excel?
SORT orders a range based on a row or column position inside that range, while SORTBY orders a range based on one or more external or internal sort arrays. SORT is simpler, while SORTBY is more flexible.
When should I use SORT instead of SORTBY?
You should use SORT when you want a simple sorted output based on a known row or column number inside the same array, such as sorting a table by the second column.
When is SORTBY the better choice?
SORTBY is the better choice when you want to sort by another range, sort by multiple criteria, or build more dynamic spreadsheet logic where the sort key should be separated from the displayed output.
Do SORT and SORTBY change the original data?
No. Both functions return a dynamic sorted result in another location and leave the original source data unchanged.
0

SORT vs SORTBY is one of the most useful modern Excel comparisons because both functions help users create dynamic sorted outputs without manually changing the source table. That matters a lot in reporting work, where people often need clean ranked views, ordered lists, dashboard tables, or filtered outputs that remain up to date as the source data changes.

For example, teams often need to:

  • sort revenue from highest to lowest
  • rank products by sales
  • order customers alphabetically
  • sort tickets by date
  • sort a filtered result by amount
  • sort a dashboard table by one measure and then by another
  • create a dynamic list without touching the raw data

Both SORT and SORTBY can help with those tasks.

The reason users compare them is that they solve similar problems in different ways. One is simpler for straightforward sorting. The other is more flexible for advanced logic and more controlled reporting workflows.

This guide explains the difference between SORT and SORTBY, how each one works, when each function makes the most sense, and how to choose the right one for practical spreadsheet work.

Overview

SORT and SORTBY are dynamic array functions in Excel.

That means they return a sorted result that spills into multiple cells automatically, instead of forcing users to manually sort the source range in place.

This is useful because:

  • the original data stays untouched
  • the sorted result updates when the source changes
  • the logic remains visible in the formula
  • reports and dashboards become easier to maintain

At a high level:

  • SORT sorts a range by a row or column index inside the selected array
  • SORTBY sorts a range by one or more ranges or arrays you choose as sort keys

That difference is what makes SORT simpler and SORTBY more flexible.

What SORT does

SORT returns a sorted version of a range or array.

The basic syntax looks like this:

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

This means:

  • array is the range you want to sort
  • sort_index tells Excel which row or column position inside the array to sort by
  • sort_order controls ascending or descending order
  • by_col is optional and controls whether sorting happens by column instead of by row

A simple example:

=SORT(A2:C10,2,-1)

This sorts the range A2:C10 by the second column in descending order.

That makes SORT very practical for simple ranked outputs.

What SORTBY does

SORTBY returns a sorted version of a range, but instead of sorting by a positional column number, it sorts using one or more sort arrays.

The basic syntax looks like this:

=SORTBY(array,by_array1,[sort_order1],[by_array2,sort_order2],...)

This means:

  • array is the output range you want to sort
  • by_array1 is the first range or array that controls the sort
  • sort_order1 controls ascending or descending order for that sort key
  • more sort arrays can be added for multi-level sorting

A simple example:

=SORTBY(A2:C10,C2:C10,-1)

This sorts A2:C10 based on the values in C2:C10 in descending order.

That may sound similar to SORT, but the flexibility is much greater because the sort key does not have to be identified only by a numeric position inside the array.

The main difference between SORT and SORTBY

The simplest way to understand the difference is this:

SORT

Sort by position.

SORTBY

Sort by range.

That means:

  • with SORT, you tell Excel which column or row position to use
  • with SORTBY, you tell Excel which range or ranges should control the order

This becomes very important when:

  • the display array is different from the sort array
  • multiple sort conditions are needed
  • the formula should remain more robust if columns move
  • the output is part of a more advanced reporting workflow

Why this comparison matters in real reporting

Sorting is not just a cosmetic step. It changes how information is interpreted.

For example:

  • a sales report sorted by highest revenue immediately shows top performers
  • a ticket report sorted by oldest date highlights backlog risk
  • a finance list sorted by unpaid balance helps prioritize collection work
  • a filtered dashboard sorted by status and then date makes operational follow-up easier

In real spreadsheet workflows, the need is often not just “sort this table.” It is “show this result in the right order for decision-making.”

That is why understanding the right sorting function matters.

SORT syntax explained

Here is the core structure again:

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

Array

This is the source range you want Excel to return in sorted order.

Example: A2:C100

Sort_index

This tells Excel which row or column position inside the array to sort by.

For example, if the selected array has:

  • column 1 = Product
  • column 2 = Region
  • column 3 = Revenue

then a sort index of 3 means sort by Revenue.

Sort_order

This controls ascending or descending sort order.

  • 1 means ascending
  • -1 means descending

So if you want highest revenue first, you would often use -1.

By_col

This optional argument controls whether the sort happens by column instead of by row.

Most everyday spreadsheet use leaves this out because sorting by rows is the normal pattern.

SORTBY syntax explained

Here is the structure again:

=SORTBY(array,by_array1,[sort_order1],[by_array2,sort_order2],...)

Array

This is the output range you want returned in sorted order.

By_array1

This is the range or array Excel should use as the first sort key.

Unlike SORT, this is not just a positional number. It is an actual sort range.

Sort_order1

Controls ascending or descending order for that sort key.

Additional sort arrays

This is where SORTBY becomes especially powerful.

You can add:

  • a second sort key
  • a third sort key
  • more advanced ordering logic

This makes SORTBY especially useful in more structured reporting.

A simple SORT example

Suppose you have:

Product Region Revenue
Laptop North 5000
Monitor South 3200
Keyboard East 1800
Mouse North 4100

To sort by Revenue from highest to lowest:

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

This sorts the selected range by the third column in descending order.

That is a classic SORT use case.

A simple SORTBY example

With the same table, you could also sort by Revenue using:

=SORTBY(A2:C5,C2:C5,-1)

This produces the same general result.

Why use SORTBY here?

In a simple example, either formula works. But SORTBY starts to show its value when the sort logic becomes more advanced or when the sort key should be specified more explicitly.

Why SORT is simpler

SORT is often easier when:

  • the output table is straightforward
  • the sort column is clearly inside the array
  • one sorting rule is enough
  • you want a short readable formula

For example:

=SORT(A2:C100,2,1)

This is very clear if you know column 2 is the field you want.

That makes SORT a good default choice for simple dynamic ordering.

Why SORTBY is more flexible

SORTBY is often better when:

  • the sort logic depends on another range
  • you want multiple sort levels
  • the display array and sort key are separated
  • you want the formula to be less dependent on column position
  • the source table may change structure over time

This flexibility matters a lot in maintained workbooks where columns may move or where the sort logic is more complex than one obvious table field.

Multi-level sorting with SORTBY

This is one of the biggest advantages of SORTBY.

Suppose you want to sort by:

  • Region ascending
  • then Revenue descending

You can do that with SORTBY more naturally.

Example:

=SORTBY(A2:C5,B2:B5,1,C2:C5,-1)

This means:

  • sort first by Region in ascending order
  • then by Revenue in descending order within those groups

That kind of multi-level sorting is very useful in operational and reporting workflows.

Can SORT do multi-level sorting?

SORT is more limited for this kind of formula-based multi-key logic.

It is excellent for simpler one-key dynamic sorting, but when users need more control over multiple sort rules, SORTBY is usually the better fit.

That is why many advanced spreadsheet users prefer SORTBY for robust reporting setups.

SORT and dynamic reporting

Both functions are very useful in dynamic reporting because they can sit on top of:

  • raw data
  • filtered data
  • unique lists
  • dashboard output tables
  • formula-based report sections

For example, a useful pattern might be:

  • FILTER to return one subset
  • SORT or SORTBY to order the result
  • UNIQUE if a distinct list is needed

This combination is one of the strongest parts of modern Excel formula workflows.

SORT with UNIQUE

A very common pattern is:

=SORT(UNIQUE(A2:A100))

This gives you:

  • a distinct list
  • in sorted order

That is excellent for:

  • dashboard lists
  • dropdown support
  • summary sections
  • reporting dimensions

SORT works very naturally here.

SORTBY with FILTER

SORTBY is especially useful after FILTER when you want a more controlled ordering logic.

For example:

  • filter one region’s records
  • then sort them by date descending
  • and then by priority ascending

That kind of logic is common in live operational tables.

Common business use cases

Finance

Finance teams use SORT and SORTBY for:

  • highest balance first
  • oldest unpaid invoices
  • ranked cost lines
  • sorted vendor lists
  • budget reviews by category and amount

Operations

Operations teams use them for:

  • oldest tickets first
  • highest-priority issues first
  • one team’s workload sorted by deadline
  • site performance lists ranked by problem count

Analytics

Analysts use them for:

  • top products by revenue
  • channels ranked by performance
  • region lists sorted alphabetically
  • filtered sub-reports ordered by value
  • dynamic sorted datasets for dashboards

These are everyday spreadsheet use cases.

Common mistakes with SORT and SORTBY

Blocked spill ranges

Both functions are dynamic arrays. If the result needs to spill into cells that already contain data, Excel may show an error.

This is one of the first things to check when the sort formula appears broken.

Wrong sort index in SORT

If the sort index points to the wrong column position, the result may be valid technically but incorrect for the reporting purpose.

This is especially risky if columns are inserted or moved later.

Wrong sort range in SORTBY

If the by_array range does not line up with the array being sorted, the output can fail or behave unexpectedly.

Alignment matters.

Using SORT when SORTBY would be safer

If the source structure changes often, a positional sort index may become fragile. In those cases, SORTBY is often the better design choice.

Forgetting sort order logic

Users sometimes expect descending order but leave the formula in ascending mode. Always confirm whether the output should rank lowest to highest or highest to lowest.

Step-by-step workflow

If you are deciding between SORT and SORTBY, this is a good process.

Step 1: Define the output

Ask: What range do I want to display in sorted form?

Step 2: Define the sort key

Ask: What should control the order?

Examples:

  • revenue
  • date
  • region
  • customer name
  • priority

Step 3: Count how many sort rules matter

If one simple rule matters, SORT may be enough. If multiple rules or more flexible logic matter, SORTBY is usually better.

Step 4: Check whether position or range is more reliable

If sorting by a fixed visible column inside the array is fine, SORT is simple. If you want to sort by explicit ranges or protect against column movement, SORTBY is often safer.

Step 5: Check the spill area

Make sure the sorted output has enough room.

Practical formula examples

SORT by revenue descending

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

SORT alphabetically by product

=SORT(A2:C100,1,1)

SORTBY by revenue descending

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

SORTBY by region then revenue

=SORTBY(A2:C100,B2:B100,1,C2:C100,-1)

SORT a unique list

=SORT(UNIQUE(A2:A100))

These examples cover many of the most common spreadsheet sorting patterns.

When SORT is the better choice

SORT is usually the better choice when:

  • the array is simple
  • the sort column is clearly inside the range
  • one sort rule is enough
  • readability and speed matter
  • you want the shortest formula for a clear task

It is excellent for many dashboard and reporting outputs.

When SORTBY is the better choice

SORTBY is usually the better choice when:

  • you need multiple sort rules
  • the sort key should be an explicit range
  • the source layout may change
  • you want more controlled formula design
  • you are building more advanced or maintainable reporting logic

That makes it especially strong for operational and analyst workflows.

FAQ

What is the difference between SORT and SORTBY in Excel?

SORT orders a range based on a row or column position inside that range, while SORTBY orders a range based on one or more external or internal sort arrays. SORT is simpler, while SORTBY is more flexible.

When should I use SORT instead of SORTBY?

You should use SORT when you want a simple sorted output based on a known row or column number inside the same array, such as sorting a table by the second column.

When is SORTBY the better choice?

SORTBY is the better choice when you want to sort by another range, sort by multiple criteria, or build more dynamic spreadsheet logic where the sort key should be separated from the displayed output.

Do SORT and SORTBY change the original data?

No. Both functions return a dynamic sorted result in another location and leave the original source data unchanged.

Final thoughts

SORT and SORTBY are both powerful modern Excel functions because they let users create dynamic sorted outputs without manually editing the source table.

The key difference is simple: SORT is based on position. SORTBY is based on ranges.

That makes SORT a great choice for clear, simple sorting tasks, while SORTBY becomes the stronger option when the logic needs more flexibility, more control, or more resilience in a changing workbook.

If you understand that distinction, choosing between them becomes much easier.

You are not really choosing between two competing features. You are choosing the right level of sorting control for the spreadsheet workflow you are building.

Related posts