Excel SORTBY Function: Complete Tutorial for Single and Multiple Column Sorting

Published: December 19, 2024 - 3 min read

Julian Alvarado

The SORTBY function in Excel revolutionizes how we sort data by allowing formula-based, dynamic sorting without altering the source data. Unlike traditional sorting methods, SORTBY maintains your original data structure while creating sorted arrays in separate locations. Available in Excel 365 and later versions, this powerful function helps you create real-time, automatically updating sorted lists.

Sort a Single Column Using SORTBY in Excel

The SORTBY function follows this basic syntax:

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

Let’s break down each component:

  • array: The range you want to sort
  • by_array1: The range that determines the sort order
  • sort_order1: Optional. 1 for ascending (default), -1 for descending
  • Additional by_array and sort_order pairs for multiple-column sorting

Example 1: Basic Single Column Sort

Let’s sort a list of products by their prices:

Product

Price

Apple

1.99

Orange

0.99

Banana

1.49

Formula:

=SORTBY(A2:A4, B2:B4)

Result:

Sorted Products

Orange

Banana

Apple

How Does SORTBY Differ from Regular Sort?

  1. Formula-Based:
  • SORTBY creates a dynamic formula that updates automatically
  • Regular Sort physically rearranges data
  1. Source Data Preservation:
  • SORTBY keeps original data intact
  • Regular Sort modifies the original dataset
  1. Real-time Updates:
  • SORTBY reflects changes immediately
  • Regular Sort requires manual re-sorting

Sort Multiple Columns with SORTBY

Example 2: Primary and Secondary Sort

Consider this employee dataset:

Department

Last Name

Salary

Sales

Smith

50000

Marketing

Jones

55000

Sales

Brown

52000

To sort by Department (ascending) and then Salary (descending):

=SORTBY(A2:C4, A2:A4, 1, C2:C4, -1)

Result:

Department

Last Name

Salary

Marketing

Jones

55000

Sales

Brown

52000

Sales

Smith

50000

Creating Custom Sort Orders

Example 3: Mixed Data Types

Consider inventory data:

Item

Priority

Stock

Laptop

High

15

Mouse

Low

50

Keyboard

Medium

30

To create a custom priority sort (High > Medium > Low):

Coefficient Excel Google Sheets Connectors
Try the Free Spreadsheet Extension Over 500,000 Pros Are Raving About

Stop exporting data manually. Sync data from your business systems into Google Sheets or Excel with Coefficient and set it on a refresh schedule.

Get Started

=SORTBY(A2:C4, MATCH(B2:B4,{“High”,”Medium”,”Low”},0))

Practical SORTBY Applications

Sales Data Organization

Example 4: Sales Performance Tracking

Rep

Region

Sales

Commission

Alice

North

50000

2500

Bob

South

75000

3750

Carol

East

60000

3000

Sort by Sales (descending) and Commission (descending):

=SORTBY(A2:D4, C2:C4, -1, D2:D4, -1)

Common SORTBY Formulas for Business Use

Example 5: Customer Database Sorting

Customer

Value

Status

ABC Corp

50000

Active

XYZ Inc

75000

Inactive

DEF Ltd

25000

Active

Sort by Status (Active first) then Value (descending):

=SORTBY(A2:C4, B2:B4, -1, EXACT(C2:C4,”Active”), -1)

Next Steps

The SORTBY function transforms how you handle data in Excel, offering dynamic, formula-based sorting that updates automatically as your data changes. Whether you’re managing sales data, organizing inventory, or maintaining customer databases, SORTBY provides a powerful solution for your sorting needs.

Ready to take your Excel data management to the next level? Discover how Coefficient can enhance your spreadsheet capabilities by automatically syncing real-time data from your business systems directly into Excel. Get started with Coefficient today and experience seamless data integration with your Excel workflows.

Sync Live Data into Your Spreadsheet

Connect Google Sheets or Excel to your business systems, import your data, and set it on a refresh schedule.

Try the Spreadsheet Automation Tool Over 500,000 Professionals are Raving About

Tired of spending endless hours manually pushing and pulling data into Google Sheets? Say goodbye to repetitive tasks and hello to efficiency with Coefficient, the leading spreadsheet automation tool trusted by over 350,000 professionals worldwide.

Sync data from your CRM, database, ads platforms, and more into Google Sheets in just a few clicks. Set it on a refresh schedule. And, use AI to write formulas and SQL, or build charts and pivots.

Julian Alvarado Content Marketing
Julian is a dynamic B2B marketer with 8+ years of experience creating full-funnel marketing journeys, leveraging an analytical background in biological sciences to examine customer needs.
500,000+ happy users
Wait, there's more!
Connect any system to Google Sheets in just seconds.
Get Started Free

Trusted By Over 50,000 Companies