Lookup & Reference
Excel 2021
◉ 6 views
Dynamic Array
=SORTBY()
Learn about the SORTBY function, which sorts the contents of a range or array based on the values in a corresponding range or array. SORTBY is in a class of functions called dynamic arrays.
Applies To:
Excel for Microsoft 365Excel for Microsoft 365 for MacExcel 2024Excel 2024 for MacExcel 2021Excel 2021 for MacExcel for iPadExcel for iPhoneExcel for Android tabletsExcel for Android phones
=SORTBY(array, by_array1, [sort_order1], [by_array2, sort_order2],…)
Hover argument names in the table for details.
Output typeArray
Popularity60 / 100
VolatileNo
Dynamic ArrayYes
📥 Download sample .xlsx — Coming soon
▦ Try in Playground
Dedicated file for this function — safe & lightweight · sample data + live formulas
⬇ Download Sample Workbook
A dedicated .xlsx for =SORTBY() with Persian sample data & live formulas — open in Excel and practice.
- Sheet “Sample” — data table + formula in place
- Sheet “Guide” — syntax, arguments & tips from this page
- Instant & secure (token + rate limit)
🧠 🧠 Quiz this function
%d questions — syntax, example & errors — test yourself!
◧ Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
array |
Array | Required | The array or range to sort |
by_array1 |
Range | Required | The array or range to sort on |
sort_order1] |
Number | Optional | The order to use for sorting. 1 for ascending, -1 for descending. Default is ascending. |
by_array2] |
Range | Optional | The array or range to sort on |
sort_order2] |
Number | Optional | The order to use for sorting. 1 for ascending, -1 for descending. Default is ascending. |
▣ Examples
ایجاد دنباله اعداد ۱ تا ۱۰
=SEQUENCE(10)
⚠ Common Errors
#VALUE!
If the sort order argument is not -1, or 1, the formula will result in a #VALUE! error.
Fix: Make the ranges the same size and check the sort order argument
💬 Comments & Q&A 0 approved
🔒 Your comment will be published after review.Share your thoughts — visible after admin approval
No comments yet — be the first!