<sort>
Changes the order in which rows appear in a table by sorting according to the values in a column.
Syntax
<sort col="[COLUMN_NAME]" dir="[SORT_DIRECTION]"/>
Attributes
col
- The name of the column (real or computed) whose values will be used to order the rows.
You can use an expression for the
col
attribute. For example,<sort col="lowercase(foo)"/>
first converts columnfoo
to lower case, and then performs the sort. dir
- The direction in which to sort:
up
ordown
. The default isup
.Valid values for
dir
up
- Sort from lowest to highest numeric value or alphabetically.
down
- Sort from highest to lowest numeric value or reverse-alphabetically.
naorder
- Tells the system to include N/A values first or last in the collation order.
first
- N/A values appear in the beginning of the collation order, the default behavior. This means they appear at the beginning when the table is sorted up, and at the end when the table is sorted down.
last
- N/A values appear at the end of the collation order. This means they appear at the end when the table is sorted up, and at the beginning when the table is sorted down.
cols
- The
cols
attribute allows for sorting by multiple columns. Provide column names in a comma-separated list.Columns are sorted in ascending order by default.
You can use expressions in the
cols
attribute. See thecol
attribute for an example.Prefixing a column name with a backtick character (`
) specifies that the column should be sorted in descending order. (Available as of prod-9)Note: You cannot use thedir
andcols
attributes together. You must use the backtick character to control the sort direction of each of the columns specified by thecols
attribute.
Example
The following example sorts the pub.demo.retail.item table such that
the values in the date
column are in descending order
(dir="down"
) and any N/A values appear at the beginning of the
sorted table (naorder="last"
).
<base table="pub.demo.retail.item"/> <sort col="date" dir="down" naorder="last"/>