[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'ComCtrls' (#lcl)

# TTreeNode.DefaultTreeViewSort

Default routine used to returns a numeric value with the sort order for the specified tree nodes.

## Declaration

Source position: comctrls.pp line 3096

`public function TTreeNode.DefaultTreeViewSort(`
`Node1: TTreeNode;`
`Node2: TTreeNode`
`):Integer;`

## Arguments

`Node1` |  | Tree node compared in the method.
`Node2` |  | Tree node compared in the method.

## Function result

Numeric value with the relative sort order for the compared nodes.

## Description

DefaultTreeViewSort is the default routine used to compare tree nodes to determine their sort order. DefaultTreeViewSort is used in the CustomSort method when a another comparison routine has not been specified in the argument for the method. It is passed as an argument to the Sort routine in the implementation section for the unit.

DefaultTreeViewSort checks for an assigned OnCompare event handler in the TreeView control for the nodes. When assigned, it is signalled to compare the specified nodes to determine the return value for the method. If TreeView or its OnCompare handler have not been assigned, the text for the nodes in Node1 and Node2 are compared to get the return value. The return values contains the following:

< 0
  Node1.Text occurs before Node2.Text in the sort order.
0
  Node1.Text and Node2.Text have the same value in the sort order.
> 0
  Node1.Text occurs after Node2.Text in the sort order.

On UNIX-like platforms, the CompareStr routine is called to compare the values for the Text in the nodes. The comparison is case-sensitive. All other platforms call the AnsiCompareStr routine to compare the Text values. AnsiCompareStr handles ANSI characters which include accented characters. The comparison is case-sensitive.

## See also

TTreeNode.CustomSort |  | CustomSort - Sorts the child nodes using SortProc.
TTreeNodeCompare |  | TTreeNodeCompare - generic function to compare Tree Nodes: returns -1 if Node1 is less than Node2, zero if equal, +1 if Node1 is greater.
TCustomTreeview.OnCompare |  | Event handler signalled to compare and sort tree nodes in their default order.