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

Peter,

I'm having difficulty visualising how you did this, even
with the numbers in front of me. Please kindly explain
using a small example.

Thanks,

Karen


-----Original Message-----
Hi Karen,

I set the minimumized weight of a item at the begin.

Every comparison
between two item will raise one item's weigh over another

by one.
Also, if the item has subitem, all its subitems will be

raise corresponding
weigh.


LEVEL ID INSTRUMENT DEVIATION


1 0 Entry Structure 100 7

7
2 0 Beverages 20 3

3 3
3 1 Allied Domecq 8 0 1

1 1
3 2 Diageo 2 0 0

0
3 3 Scottish Newcastle 10 0

2 2
2 0 Mining 30 2

6 6
3 4 GOC 10 0 0

4 4
3 5 Rio Tinto 20 0 1

5 5

Did this works work for you?


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and

confers no rights.
--------------------
From: (Karen Lee)
Newsgroups: microsoft.public.excel.programming
Subject: VBA: Sorting arrays in hierarchichal data

structu Help!!!
Date: 12 Sep 2003 02:17:42 -0700
Organization:
http://groups.google.com/
Lines: 81
Message-ID:


References:


NNTP-Posting-Host: 193.108.78.10
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1063358263 24166 127.0.0.1

(12 Sep 2003
09:17:43 GMT)
X-Complaints-To:
NNTP-Posting-Date: 12 Sep 2003 09:17:43 GMT
Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!

newsfeed00.sul.t-online.de!newsfee
d01.sul.t-online.de!t-online.de!newspeer1-

gui.server.ntli.net!ntli.net!sn-xi
t-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!

postnews1.google.com!not-fo
r-mail
Xref: cpmsftngxa06.phx.gbl

microsoft.public.excel.programming:415240
X-Tomcat-NG: microsoft.public.excel.programming

Is probably a bit more clearer if data is shown like

this:

Original structu

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


After Sorting:

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

Order of data is: Level No, Instrument ID, Name,

Deviation

Note that Group Headers have ID of zero.

I'm looking for an algorithm which can perform the

sorting with the
least hassle and best performance, using either arrays

or collections.


Rgds,

K



(Karen Lee) wrote in message

.com...
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............



.