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.
I have worked through an example, hoping this makes what is needed a little clearer.
Thank you in advance for any and all support.
I need a small piece of code that will read an ASCII Delimited file and sort it, with the following rules.
This might seem complicated, but I think a good tight loop or two should accomplished what is needed.
NOTE: the tabs and delimiters need to remain so it can be re-read into a TREEVIEW.
INPUT: Tab delimited ASCII File.
OUTPUT: Tab delimited ASCII File with values ending with an "*" are sorted to the end of their node.
-This file should be thought of as a TREE Structure
-The left side of the labels. DO NOT MOVE
-The right side of the labels DO MOVE
-The left and right are determined by the first space on the right side
So using this as an example: AA 8975043*
AA+SPACE(8) is the left label
8975043* is the right label
AA+SPACE(8) will not move
8975043* - since it ends with an "*" will be moved to the end of the NODE
1. All right labels ending with an "*" need to be moved/sorted to the end of their node
2. Start with the second level and sort the items ending with an "*" to the end of that node
NOTE: the AA, AB, AC, AD labels DO NOT MOVE
3. The values under each node ARE MOVED AS WELL.
I would think this all could be easily accomplished with an internal data structure that you create, without creating any external files or databases. Then again, I am a C++ programmer. When I used to program in VB, I would create a user defined type to represent the nodes in a tree data structure. Then I would create an array of these nodes and use the array indexes as pointers. (I love pointers. )
Maybe you could put the data into a two dimensional array with a column for each level. Then sort the table as if the all of the columns are one big column. Then relabel the left side of the labels so that they are in order. When you extract the data from the sorted table, check if the left side of each label is different than the previous row. This will indicate that the previous row was a leaf in the tree.