String comparison to consider numbers
c#, sorting, treeview, winforms
Solution
Have a read of http://www.dotnetperls.com/alphanumeric-sorting . You may need to strip out everything else though to get their solution to work - as they sort either numerically or alphabetically.
If it's a dynamic filename, you may be best using a regex to just match the parts you want to sort by.
Problem
I am trying to sort nodes of a treeview with respect to their text property of course. The problem is that my comparison class does not care about numbers. Here is the code: ``` public class TreeNodeSorter : IComparer { public int Compare(object x, object y) { var tx = x as TreeNode; var ty = y as TreeNode; return string.Compare(tx.Text, ty.Text); } } ``` And here is the result: The first child node (Debug...) is ok, but my problem is why on earth "HBM\D10" is sorted before "HBM\D7" and so on...