Sort() function

Sort(array, column1, order1 [, column2, order2, column3, order3])

Sorts an array/range based on the specified (column, sorting order) pairs and returns the result as a vector of the corresponding rows indices.

The 1-based column indices specify the relative column positions within the source range.

The sorting orders be one of two values:
0 - descending order
1 - ascending order.

Use the 'index' function to obtain the final sorted array.

Sort() examples:

=sort({3; 1; 5; 2; 4}, 1, 1) returns {2; 4; 1; 5; 3}

=sort({3; 1; 5; 2; 4}, 1, 0) returns {3; 5; 1; 4; 2}

=sort({2, "b"; 2, "a"; 3, "d"; 3, "c"; 1, "e"}, 1, 1, 2, 1) returns { 5; 2; 1; 4; 3}

=index({2, "b"; 2, "a"; 3, "d"; 3, "c"; 1, "e"}, {5; 2; 1; 4; 3}, 1) returns {1; 2; 2; 3; 3} where {5; 2; 1; 4; 3} is the result of the above sorting.

You can insert the Sort() function with just two clicks using the Insert > SORT() command. The displayed "Insert SORT()" dialog box determines the optimum parameters including the option to copy styles from the selected source data range and automatically creates the formula.

The source range 16 element list is a global list created and stored in the settings file. Subsequent source ranges are added in a circular manner by clicking one of the following:

The "Copy as Location" menu command

The "Enter" toolbar button