sortColumn

Type: Integer array

Availability: Read or write at run time only

The sortColumn property of the Table control sets the column number for which the text is to be sorted. Each sheet of a table control can have in the range zero through six sorted columns. The sorting sets these properties for the sheet, as required. Each sheet has an array of six items (the entries are 1‑relative).

The column numbers can be established at any time and are not validated when set. If the column is invalid, it is ignored when sorted.

If a sort column is zero (0), the remaining sort column values are ignored. If no sort column is set, no sorting is performed.

When the text of a sorted column changes, the automatic sorting of rows occurs only when the Table class addItem method adds a new row or the Table class resort method is used. (The resort method is ignored if no columns are set; that is, when the sortColumn property is set to zero.)

As the number of rows can initially be set, the table control keeps a record of the highest row that has had text set. The sort involves only the rows up to and including that row. Fixed rows are not sorted.

The code fragment in the following example sorts the table based on three columns: 4, 1, and 7. Column 4 is sorted in ascending order, column 1 in descending order, column 7 in ascending order, and no columns are sorted by case; that is, they are case-insensitive.

table1.sortColumn[1] := 4;    // first sort column is 4
table1.sortAsc[1]    := true;
table1.sortCased[1]  := false;
table1.sortColumn[2] := 1;    // second sort column is 1
table1.sortAsc[2]    := false;
table1.sortCased[2]  := false;
table1.sortColumn[3] := 7;    // third sort column is 7
table1.sortAsc[3]    := true;
table1.sortCased[3]  := false;