Skip to main content
Workday User Guide
Last Updated: 2023-06-23
SORT

SORT

Description

Sorts an existing matrix and returns a new matrix. SORT() accepts one sort direction and sorts all columns you specified based on that direction.

Syntax

SORT(
matrix
, [
ascending
], [
sort_column
], ...)
  • matrix
    : The matrix to sort.
  • ascending
    : If TRUE, the values are sorted in ascending order; if FALSE, the values are sorted in descending order. The default is TRUE.
  • sort_column
    : One or more column names or column positions to use as the columns to sort on. If you don't specify any columns, then the first (left-most) column is used.

Example

This is the original spreadsheet:
A
B
C
D
E
1
Name
Grade
2
Joe
85
3
Alice
92
4
Joe
90
The result of
=SORT(A1:B4,true,"Name","Grade")
is:
Name
Grade
Alice
92
Joe
85
Joe
90

Notes

  • To specify a different sort direction for each column being sorted, use SORT2().
  • This function sorts the rows in the source
    matrix
    and returns a new matrix reflecting the sorted rows. The order of the rows is determined by the values in the
    sort_column
    and the direction you specified (ascending or descending).
  • Specify sort columns either by name (as text strings without any surrounding square brackets) or by position (where the first column is in position 1). You can mix these values (specifying some by name and others by position).
  • When you specify more than one sort column, the function breaks ties by sorting the values in each subsequently specified column. Example: If the first column has three values of the string
    "hello"
    , and you specified a second column, the function sorts the values in that column for the three rows that have
    "hello"
    in the first column. This determines the final order of those three columns.
  • This function is intended for use in array formulas.

Related Functions

ARRAYAREA
SORT2