DB_Table.sort
sortcolumns text_orderingerror_on_missing_columnson_problems
Group: Selections
Aliases: sort
Documentation
Sorts the rows of the table according to the specified columns and order.
Arguments
columns
: The columns and order to sort the table.text_ordering
: The ordering method to use on text values.error_on_missing_columns
: Specifies if a missing input column should result in an error regardless of theon_problems
settings. Defaults toTrue
.on_problems
: Specifies how to handle problems if they occur, reporting them as warnings by default.
Examples
Sorting table
in ascending order by the value in column 'Quantity'
.
table.sort ['Quantity']
Sorting table
in descending order by the value in column 'Quantity'
.
table.sort [..Name 'Quantity' ..Descending]
Sorting table
in ascending order by the value in column 'Quantity'
,
using the value in column 'Rating'
for breaking ties.
table.sort ['Quantity', 'Rating']
Sorting table
in ascending order by the value in column 'Quantity'
,
using the value in column 'Rating'
in descending order for breaking
ties.
table.sort [..Name 'Quantity', ..Name 'Rating' ..Descending]
Order the table by the second column in ascending order. In case of any
ties, break them based on the 7th column from the end of the table in descending order.
table.sort [1, ..Index -7 ..Descending]
Sort the table by columns whose names start with letter a
.
table.sort [(..Select_By_Name "a.*".to_regex case_sensitivity=..Insensitive)]
Errors
- If a column in
columns
is not in the input table, aMissing_Input_Columns
is raised as an error, unlesserror_on_missing_columns
is set toFalse
, in which case the problem is reported according to theon_problems
setting. - If no columns have been selected for ordering,
a
No_Input_Columns_Selected
is raised as dataflow error regardless of any settings. - If a column used for ordering contains values that cannot be
compared, an
Incomparable_Values
error is raised.
Remarks
Missing Values
Missing (Nothing
) values are sorted as less than any other object.