SheetRocks
Documentation/Formulas/SORT

SORT

Sorts the values in a range or array.

Syntax

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

Arguments

Argument Description Required
array The array or range to sort. Required
sort_index The column index to sort by (1-based). Defaults to 1. Optional
sort_order The sort order: 1 for ascending (default), -1 for descending. Optional

Examples

Sort single column ascending

=SORT(A1:A3)
Result ⇒ Array: [[10], [20], [30]]
A
1 30
2 10
3 20

Sort by specific column descending

=SORT(A1:B3, 2, -1)
Result ⇒ Array: [["Jane",30], ["John",25], ["Bob",20]]
A B
1 John 25
2 Jane 30
3 Bob 20

Sort names alphabetically

=SORT(A1:A3, 1, 1)
Result ⇒ Array: [["Alice"], ["Bob"], ["Charlie"]]
A
1 Charlie
2 Alice
3 Bob

Related Functions

Other Data functions:


← Back to Formula Reference