|
Sorts table information in ascending or descending order.
syntax
SortTable(
valTable,
[,column = ""]
[,type = ""]
[,reverse = FALSE]
)
Parameters
valTable
|
|
Type:
|
General purpose
|
|
Specifies the table data to be sorted. Multiple values can be specified as an array.
|
column
|
|
Type:
|
character
|
|
Specify the column you want to sort.
Example: 0 - Sort by the 0th column
Example: 5 - sort by the 5th column
Example: c(5, 2) - sorts the 5th column first, then the 2nd column
Example: c(5, 2, 0) - sorts the 5th column first, then the 2nd column, then the 0th column
|
type
|
|
Type:
|
character
|
|
Type specification.
"" - Automatic
"text" - Sort based on values converted to text
"number" - Sort based on the converted number
"time" - Sort by the converted time value
|
reverse
|
|
Type:
|
Boolean
|
|
TRUE - descending
FALSE - ascending
|
Return Value
|
|
Type:
|
character
|
|
The index information that was sorted.
|
Example
To sort array data by specifying multiple (or mixed) sort keys, sort orders, or data types
|
var vTable, vSortIndex, vNewData;
vTable = c(c("A", "D", "B", "D"), c("1","2","1", "3"));
// Sort "vTable" in ascending order of the first dimension (characters) and descending order of the second dimension (numbers).
vSortIndex = ::SortTable(vTable, c(0, 1), c("text", "number"), c(F, T));
// "vSortIndex" returns the index of the result of sorting under the above conditions as a one-dimensional array.
// As shown below, you can obtain the sorted array result by specifying the returned value "vSortIndex" to the original data array "vTable".
vNewData = vTable[ , vSortIndex];
|
vNewData stores the sorted data "c(c("A", "B", "D", "D"), c("1","1","3","2"))".
|
Supported
reference
SelectVal (SV)
GetRemainder
Nums
RepeatValue
SortValue
GetUniqueValue
IsExist
|