2 using System
.Collections
;
4 using System
.Windows
.Forms
;
8 public class NodeSorter
: IComparer
10 public int Compare(object x
, object y
)
12 TreeNode tx
= x
as TreeNode
;
13 TreeNode ty
= y
as TreeNode
;
15 // Compare the length of the strings, returning the difference.
16 if (tx
.Nodes
.Count
> 0 && ty
.Nodes
.Count
< 1)
18 if (tx
.Nodes
.Count
< 1 && ty
.Nodes
.Count
> 0)
21 return string.Compare(tx
.Text
, ty
.Text
);