sort() | Additional XPath Functions
--- | ---

## sort

Sort a node set by the specified sort keys.

Function Summary
minimal arguments | NodeSet sort (XPath expression, String sortKey)
all arguments | NodeSet sort (XPath expression, String sortKey, String sortKey2, ...)

Required Arguments
XPath expression | an XPath expression identifying the nodes to sort
String sortKey | a quoted String containing an XPath expression for a sort key. The XPath expression is evaluated relative to each node in the node set being sorted. Optionally, the string my be suffixed with ::ascending or ::descending to indicate sort direction. The default sort direction is ascending.

Optional arguments
String sortKeyN | a secondary sort key should previous keys have resulted in equality. Format rules are as with sorkKey.

Example
sort(/phonebook/entry, '@lastName') returns a node set of phone book entries sorted by lastName sort(/phonebook/entry, 'substring(@lastName, 1, 1)::descending', @firstName::ascending) returns a node set of phone book entries sorted in reverse order by the first letter of lastName and, within each letter, alphabetically by firstName

© Copyright IBM Corporation 2000, 2008. All Rights Reserved.