SORT
Applies to PredictiveInsight only.
Syntax
SORT(column [, keyword]) SORT(column, data [, keyword])
Parameters
column
In the first format (no data provided), this is the column of data to sort (numerical or text). This can be a constant, a column, or single-column cell range, or an expression evaluating to one of the above. This data range cannot contain more than values.
data
When this parameter is provided, it is the data to sort using column as the sort criteria (data can contain columns of numerical data and text). The data parameter can be a column, a cell range, or an expression evaluating to any of the above. For the format definition of data, see the "Macro Function Parameters" section in the chapter in this guide for your IBM® product. This data range cannot contain more than rows.
keyword
This optional keyword determines whether the values are sorted in increasing (minimum to maximum) or decreasing (maximum to minimum) order. Select one of the following:
ASCEND - Sort data in ascending (increasing) order (default)
DESCEND - Sort data in descending (decreasing) order
For more details on using keywords in IBM® Campaign, see Format Specifications.
For more details on using keywords in IBM® PredictiveInsight, see Format Specifications.
Description
SORT sorts the values in the specified data range (either column or data based on column) based on the keyword value (ASCEND or DESCEND). It returns one new column for each input column to be sorted. If only column is provided, the values in column will be sorted in ascending or descending order as specified by the keyword parameter. For a column of text, ascending order is alphabetical order (a-z) and descending is the reverse order (z-a). If data also is provided, it will be sorted using column as the sort criteria.
*
If a single-column cell range is provided for column, to sort the corresponding rows of data, you must specify the same cell range for data. Otherwise, the default is to sort the first n rows of data. For example, to sort corresponding rows, specify: TEMP = SORT(V1[100:200], V2[100:200]:V5) Otherwise, TEMP = SORT(V1[100:200], V2:V5) is equivalent to: TEMP = SORT(V1[100:200], V2[1:101]:V5)
Examples
TEMP = SORT(COLUMN(5, 3, 2, 4, 1)) or TEMP = SORT(COLUMN(5, 3, 2, 4, 1), ASCEND)
Creates a new column named TEMP containing the values 1, 2, 3, 4, and 5.
Creates a new column named TEMP containing the strings a, b, and c.
Creates a new column named TEMP containing the values 15, 14, 13, 12, 11, and 10.
Creates a new column named TEMP containing the values in column V1 sorted in ascending order.
Creates three new columns named TEMP, VX, and VY. The values in the TEMP column are the sorted contents of column V1 in ascending order. The values of the VX column are the corresponding contents of column V2, and the values of the VY column are the corresponding contents of column V3.
Creates a new column named TEMP, where the first 11 cells contain the sorted values of the cells in rows 10-20 of column V1, in descending order. The other cells in TEMP are empty.
TEMP = SORT(V1[5:10], V2) or TEMP = SORT(V1[5:10], V2[1:6])
Creates a new column named TEMP, where the first 6 cells contain the values from rows 1-6 of column V2, sorted in descending order of cells 5-10 of column V1. The other cells in TEMP are empty.
Creates a new column named TEMP, where the first 6 cells contain the sorted values of the cells in rows 5-10 of column V2 according to descending order of cells 5-10 of column V1. The other cells in TEMP are empty.
TEMP = SORT(V1[10:50], V2:V3) or TEMP = SORT(V1[10:50], V2[1:41]:V3)
Creates two new columns named TEMP and VX, each with values in rows 1-41 (the other cells are empty). The values in column TEMP are the values from rows 1-41 of column V2, sorted according to rows 10-50 of column V1. Similarly, the values in column VX are the values from rows 1-41 of column V3, sorted according to rows 10-50 of column V1. Column V1 is sorted in ascending order.