resort

resort();

The resort method of the Table class resorts the contents of the current sheet of a table control. This method uses the sort parameters specified in the sortColumn, sortAsc, and sortCased properties.

Use this method, for example, to resort the table by a particular column when the user clicks on the fixed column cell. The logic required to perform this action is shown in the code fragment in the following example.

if table1.row = 1 then
    table1.sortColumn[1] := column;
    table.resort;
endif;

The resorting of a table may cause rows of the table to be reordered. The current row of the table is adjusted if it is affected.

The resort method is ignored if no columns are set.

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 method in the following example shows the use of the resort method.

vars
    indx  : Integer;
    count : Integer;
begin
    if table.row = 1 and table.column > 1 then
        table.sortColumn[1] := table.column;
        table.resort;
        count := table.rows - 1;
        indx  := 1;
        while indx <= count do
            table.setCellText(indx + 1, 1, indx.String);
            indx := indx + 1;
        endwhile;
        table.row    := 1;
        table.column := 1;
        table.clearAllSelected;
    endif;
end;