How to Use SORT and SORTBY Functions in Excel 365

The SORT and SORTBY functions in Excel 365 are part of the dynamic array family — they allow you to sort data easily, flexibly, and without altering the original range.


🧠 1. SORT Function in Excel

🔧 Syntax:

SORT(array, [sort_index], [sort_order], [by_col])
ArgumentDescription
arrayThe range or array to sort
sort_indexColumn or row number to sort by (default is 1)
sort_order1 = Ascending, -1 = Descending
by_colTRUE = sort by columns, FALSE = by rows (default)

Real-Life Example: Sorting Employee Salaries

You have the following data in A2:B6:

NameSalary
Ravi35000
Priya42000
Neha39000
Akash30000
Anjali45000

Formula to sort by Salary (ascending):

=SORT(A2:B6, 2, 1)

✅ Output:

NameSalary
Akash30000
Ravi35000
Neha39000
Priya42000
Anjali45000

Formula to sort by Salary (descending):

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

🧠 2. SORTBY Function in Excel

The SORTBY function is more flexible — it allows you to sort one array based on another.

🔧 Syntax:

SORTBY(array, by_array1, [sort_order1], [by_array2], [sort_order2], ...)
ArgumentDescription
arrayThe data to sort
by_array1The column/array to sort by
sort_order11 = Ascending, -1 = Descending

Real-Life Example: Sort Students by Marks in Another Column

StudentRoll NoMarks
Aman10287
Kirti10192
Mohan10476
Preeti10389

Formula to sort by Marks (descending):

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

✅ Output:

StudentRoll NoMarks
Kirti10192
Preeti10389
Aman10287
Mohan10476

🔄 SORT vs SORTBY: What’s the Difference?

FeatureSORTSORTBY
Sort by positionYesNo
Sort by other dataLimited✅ Full flexibility
Multiple criteriaLimited✅ Supports multiple arrays
Practical use casesTables, visible dataSort by hidden/helper columns

🎯 Real-World Use Cases

  • Sort sales data by amount or date
  • Sort student scores without rearranging original data
  • Sort project tasks by deadline
  • Sort inventory by stock level using helper columns

🎓 Want to Learn More Excel Sorting & Automation Tricks?

Explore how to use Excel 365’s new tools like SORT, FILTER, TAKE, UNIQUE, and more in real business applications.

🔗 Mastering MS Excel – A Comprehensive Training Course

✅ Covers:

  • Smart Excel functions (SORT, FILTER, XLOOKUP)
  • Dashboards & automation
  • Excel VBA and real-life case studies

🎯 Click Here to Enroll Now


On sale products