Script functions reference > Script functions in alphabetical order > S > StXPathSortNodeSet

StXPathSortNodeSet
Syntax
StXPathSortNodeSet(XPath, locale, type, num_order
);
XPath
locale
type
0 – Text sorting
1 – Numeric sorting
order
0 – Ascending
1 – Descending
Description
Sorts the node set that has been pushed onto the data context memory stack. The sorting is performed based on the provided parameters.
If you want to sort the node set using different sort keys, you can invoke the function mutliple times. Becuase the sorting is stable, the order is preserved unless each sorting changes the order of the nodes. This means that for each sorting operation the result from the previous sorting is considered the original order.
For the desired result, the sorting operations must be done using the least significant sorting key first, and the most significant last. For example, you want to primarily sort countries, but you also want to sort the cities within a country. Then you must sort the cities first, and then the countries.
Returns
N/A
Example
StXPathPushNodeSet("/data/message/item[number(value)>100");
StXPathSortNodeSet("item_description", "en-US", 0, 0);
StXPathSortNodeSet("value", "", 1, 1);
while(StXPathNextPosition())
{
	   log(1, StEvalXpath("item_description"));
}
StXPathPopNodeSet();
OpenText StreamServe 5.6 Updated: 2013-03-01