Hello:
Many may have seen the struggle I am having with sorting a TREEVIEW. After many, many hours I am trying to think of another way of accomplishing this.

I thought perhaps I could write the TV to an ASCII file, then sort that file and then relabel it, followed by a re-reading into a TV.

So, if I can get any help it would be greatly appreciated.

I am able to export the file to an ASCII TAB Delimited file as follows:

Code:
A    75023
	AA        75043
		AAA       75045
			AAA1      95045
			AAA2      15045
			AAA3      35045
			AAA4      55045
		AAB       75047
			AAB1      95047*
			AAB2      15047
			AAB3      35047
			AAB4      55047
	AB        75063*
		ABA       75065
			ABA1      95065
			ABA2      15065
			ABA3      35065
			ABA4      55065
		ABB       75067
			ABB1      95067
			ABB2      15067
			ABB3      35067*
			ABB4      55067
	AC        75083*
		ACA       75085*
			ACA1      95085
			ACA2      15085
			ACA3      35085
			ACA4      55085
		ACB       75087
			ACB1      95087
			ACB2      15087
			ACB3      35087
	AD        75003
		ADA       75005
			ADA1      95005
			ADA2      15005
			ADA3      35005
			ADA4      55005
		ADB       75007
			ADB1      95007
			ADB2      15007
			ADB3      35007
So now what I need to do is sort anything that ends with an "*" to the bottom of its section/node.
I have to keep the integrity of the the nodes and tab delimited file, so I can read it back in.

Start at the highest level.. And sort everything ending with an "*" at that level to the bottom. (Within that node)

So (Level2) AB and AC will go to the end. AND everything under it.

Next go to the next level (Level3) ACA will go to the end of it's level.

Next go to the next level (level4). AAB1 will go after AAB4 and ABB3 will go after ABB4.

The output would look something like this:
Code:
A    75023
	AA        75043
		AAA       75045
			AAA1      95045
			AAA2      15045
			AAA3      35045
			AAA4      55045
		AAB       75047
			AAB2      15047
			AAB3      35047
			AAB4      55047
			AAB1      95047*
	AD        75003
		ADA       75005
			ADA1      95005
			ADA2      15005
			ADA3      35005
			ADA4      55005
		ADB       75007
			ADB1      95007
			ADB2      15007
			ADB3      35007
	AB        75063*
		ABA       75065
			ABA1      95065
			ABA2      15065
			ABA3      35065
			ABA4      55065
		ABB       75067
			ABB1      95067
			ABB2      15067
			ABB4      55067
			ABB3      35067*
	AC        75083*
		ACB       75087
			ACB1      95087
			ACB2      15087
			ACB3      35087
		ACA       75085*
			ACA1      95085
			ACA2      15085
			ACA3      35085
			ACA4      55085
If someone can help me with this, it would be greatly appreciated.

The next step would be to then go back through the newly sorted file and rename the left side of the values. AA, AAA, AAA1, etc. back to the original order. So, if you can provide that piece of code as well, it would be greatly appreciated. But I think I can figure that part out, if I can just get some help with the sorting of the file.

Thanks in advance.
k