Language Reference Guide : 4. System Classes : Tree Class : Sort Method
 
Share this page                  
Sort Method
The Sort method sorts treenodes on one attribute or on an array of attributes.
This method has the following syntax:
integer = Tree.Sort([node = TreeNode, recursive = integer],
          attributename = order {, attributename = order})
This method has the following parameters:
node
(Optional) Specifies the node whose children are to be sorted. If NULL or not specified, the root node and its siblings are to be sorted.
recursive
(Optional) Specifies whether the sort operation is recursive. If TRUE, then all descendants of the node are sorted; or if the specified node is NULL, the whole tree is sorted. If FALSE, only one set of siblings is sorted.
attributename
(Required) Specifies one of the following attributes of Treenodes:
TextLabel
KeyLabel
IsChecked
IsExpanded
IsHidden
IsSelected
The order must be AS_ASC (ASCII ascending) or AS_DESC (ASCII descending). For Boolean attributes the order is based upon 0->1 is ascending, 1->0 is descending.
When the sort is done, the visual display of the TreeviewField will reflect the sorting of the tree. The sort method returns ER_OK if successful, or a non-zero value if it is not.
order
(Required) Specifies the sort order. Valid values are AS_ASC (ASCII ascending) or AS_DESC (ASCII descending). For Boolean attributes the order is based on 0->1 is ascending, 1->0 is descending.
When the sort is done the visual display of the treeviewfield will reflect the sorting of the tree. The sort method returns ER_OK if successful or a non-zero value if it is not. Descriptions of system constant values and their numeric equivalents are listed in Error Codes.