Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting multiple arrays 1

Status
Not open for further replies.

intrex

IS-IT--Management
Apr 14, 2002
70
US
I have several arrays that I am using to build a table. Each array represents one column of data for the table. I have gotten to the point that I want to enable users to be able to click on a table header and sort all of the data in the column corresponding to that header.

Does anyone know of a brilliant way to sort one array and keep the data from the other arrays bound to the array that was sorted?
 
I will leave the response to your question to someone else who has done this, but is there a special reason why you are loading columns of data into arrays? Does creating a sortable DataView not solve your needs? If you are grabbing data from a database, then this is a pretty simple route to take. Thanks

regards,
Brian
The problem with doing something right the first time is that nobody appreciates how difficult it was.
 
I am grabing extremely large xml files (several mbs each). The high level objects for manipulating xml were all too slow. I used the xmltextreader to parse the data into arrays.
 
Sorting Multiple arrays by key contained in one.
Code:
' Create array of Keys
' ary1st, ary2nd and ary3rd are arrays to be sorted
' ALl arrays are the same size.
' Create Key array from selected array
Dim Kys(ary1st.length - 1) as String
For I = 0 to Kys.Length - 1
    Kys(I) = aryxxx(I) ' Extract keys from array to sort on
Next

Dim KysCopy(Keys.Length - 1) As String 
' Copy array and sort copy each time.
Kys.CopyTo(KysCopy,0)
System.Array.Sort(KysCopy, ary1st)

Kys.CopyTo(KysCopy,0)
System.Array.Sort(KysCopy, ary2nd)

Kys.CopyTo(KysCopy,0)
System.Array.Sort(KysCopy, ary3rd)

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Thanks,

I will let you know how this goes. I will try this tommorow morning.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top