"sort"

Sorts the table by columns.

Synopsis

setValue(string shape, "sort", [bool/dyn_bool ascending = true], string Name1 [, string Name2 ...]);

shape.sort([bool ascending = true], string Name1 [, string Name2 ...]);

Parameters

Parameter Description
shape Name of the object
ascending

TRUE = Sort ascending

FALSE = Sort descending

You can also sort by multiple columns, each having their own ascending or descending order. For this, use the dyn_bool parameter. See the example further on.

Name Column names

Description

All elements of a column must be of the same data type in order to allow sorting. Langtexts are sorted according to the active language and an online switch of the languages can cause problems because arrays seems to be sorted whereas they are not.

The parameters are the names of the columns that you want to sort in a specific order. The table will then be sorted by cell values.

If the sort by the first column parameter does not return an unambiguous sort order, the ambiguous cases are decided on the basis of the second (third or further) column parameter.

The rows of the columns to be sorted with the smaller value are placed before lines with greater values. Strings are sorted according to the current locale.

Since "sort" can take any number of parameters when used in connection with setMultiValue(), "sort" may only be passed as the final parameter.

If a "sort" has been set for a table and one of the following functions is called afterwards, the sorting will not be valid anymore:

appendLine

appendLines

insertLineN

insertLinesN

cellValue (only if the value that has been set via cellValue is set for a sorted column)

cellValueRC (only if the value that has been set via cellValue is set for a sorted column)

Example

The following example sorts a table by the columns "Last name", "First name" and "Age". If the "Surname" matches, the table will be additionally sorted by "First name". If "Surname" and "First name" match, the final criterion for sorting will be "Age".

main()
{
  table.sort("Surname", "First name", "Age");
}

The following example sorts a table by three columns, the first column descending and the two remaining columns ascending.

main()
{
  dyn_bool sort;
  sort[1] = 0;
  sort[2] = 1;
  sort[3] = 1;
  TABLE1.sort(sort,"#1","#2","#3");
}

Assignment

Table