Sort function
Sort lists and tables
Description
The Sort function sorts the elements of a list or table according to their values in ascending order.
Tables
In the case of a table, the number of a column can be optionally specified according to which the rows are sorted. If no column is specified, the values are sorted line by line.
Syntax
Sort(list)
Sort (table, column)
Example with list
a=Rnd(New(12, 20))
a= 4 0 18 8 10 6 8 3 7 15 12 12
Sort(a)=0 3 4 6 7 8 8 10 12 12 15 18
Example with invalid value
Invalid values, eg infinity or texts are placed unsorted at the end of the list.
b = [1,3,6,-1,(1/0),8,2]
b=1 3 6 -1 ∞ 8 2
Sort(b)= ∞ -1 1 2 3 6 8
Example without column number
In tables, rows are sorted in ascending order from left to right if no column is specified
Example with column number
If a column number is specified, the rows are sorted by the values in the specified column. The order in the individual lines is not changed.