Sort lists and tables
The Sort function sorts the elements of a list or table according to their values in ascending order.
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.
Sort(list)
Sort (table, column)
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
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
In tables, rows are sorted in ascending order from left to right if no column is specified
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.