Sort method of the rtTable class allows to sort table either by numeric or alphanumeric values contained in column. Sorting may be done by several columns in ascending or descending order. Text sort will always use collation order of current code page.
The parameters - keys, alphanumeric and direction may be arrays in case sort is performed on several columns.
keys - either a single column number or an array of column numbers
alphanumeric - either single True (alphabetic)/False (numeric) value or an array - one for each column
direction - True (ascending)/False (descending)
head - number of header rows to exclude from sorting
sortemptybehind - True - empty cells are always at the end, False - sorts either first or last depending on "direction
We are going to sort by 2 columns - hence 2 dimensional arrays to hold keys:
Dim keys(1) as Integer ' contains column numbers to be sorted by
Dim isAlpha(1) ' boolean array of sorting type
keys(0) = 2
keys (1) = 1 ' first sort by 2nd column then by first
isAlpha (0) = True
isAlpha (1) = True ' both alphabetic
directions(0) = True ' ascending
directions(1) = False ' descending
table.sort keys, isAlpha, directions, 1, True ' this sorts table by 2 columns skipping one header row and sorting empty values at the end
or alternative syntax if we sort by only one column:
table.sort 1, False, False, 2, True ' sort by 1st numeric column, descending order, 2 header rows, sort empty rows at the end
Split and merge methods of rtTable class allows to split table after particular row or append another table at the end.
set newtable = table.Split (10) ' will split object table after 10th row and return the new object (containing rows starting with 11th)
newtable.MergeTable table ' adds original table (rows 1-10) at the end of newtable object
' effect of these 2 staments is placing of first 10 rows at the end of the table
Transpose method will transpose the row<-->column indexes.