SORT (PQL - xl)

This function sorts the data in a cell range or an array. The cell contents are extracted from the source array, the data is sorted and the results spill into the resultant range with a dynamic array of values arranged in ascending or descending order. Users can sort the values by one or more columns in the spreadsheet as per custom requirements

  • Library: PQL \ Spreadsheet \ Lookup
  • Compatibility: Any content (regardless of data source) in the Tabulate spreadsheet module

Syntax

SORT(array, OPTIONAL sort index, OPTIONAL sort order, OPTIONAL by col)

Function Arguments

Name

Description

Type

Optional

array

Specifies the range or array that you want to sort

StringOrNumber

sort index

Specifies the column index of the row or column to sort by. If nothing is specified, the default value 1 is used

Number

Y

sort order

Specifies the sort order. The value 1 indicates ascending order and the value -1 indicates descending order. The default value is 1 i.e. ascending

Number

Y

by col

If this argument is TRUE, it refers to the 'sort by column' operation and if FALSE, it refers to the 'sort by row' operation. The default value is Boolean FALSE i.e. the sort by row operation

StringOrNumber

Y

Comments

This function is the same as the Microsoft Excel 'SORT' function - using the same inputs, logic and outputs.