View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Karen Lee Karen Lee is offline
external usenet poster
 
Posts: 2
Default VBA: Sorting arrays in hierarchichal data structu Help!!!

Help! i have spent many hours poring over this so i hope somebody out
there has some ideas:

I have some data which kind of looks like the following in it's
simplest form:

LEVEL ID INSTRUMENT DEVIATION
1 0 Entry Structure 100
2 0 Beverages 20
3 1 Allied Domecq 8
3 2 Diageo 2
3 3 Scottish Newcastle 10
2 0 Mining 30
3 4 GOC 10
3 5 Rio Tinto 20


The data is stored in an array let's say in this example: varData(8,
4)
(8 rows, 4 columns)

I am trying to develop an algorithm to sort the data by DEVIATION in
hierarchical order - that is, sort everything at level 1 first, then
2, then 3.

Once sorted the data will look like this:

1 0 Entry Structure 100
2 0 Mining 30
3 5 Rio Tinto 20
3 4 GOC 10
2 0 Beverages 20
3 3 Scottish Newcastle 10
3 1 Allied Domecq 8
3 2 Diageo 2

It looks simple enough but once you start working on it you end up
going around in circles and then get confused/frustrated/give up/go
mad. I'm working with much more levels than this and it's not nice.

Anyone help? I'm slowly going insane............