Alpha multidimensional array sort

G

glbdev

I have a multidimensional array with 5 keys. I need to perform a
alpha sort on the 3rd key. Does anyone have an example on how to do
this?

Here is an example of what my array consists of:

mArray(i,0) = '2007-05-02"
mArray(i,1) = "6:00pm"
mArray(i,2) = "TEXT TEXT TEXT" <------------------ NEED TO DO ALPHA
SORT ON THIS KEY ----------------<<
mArray(i,3) = 6
mArray(i,4) = 4


Thanks,
Steve
 
B

Bob Barrows [MVP]

I have a multidimensional array with 5 keys. I need to perform a
alpha sort on the 3rd key. Does anyone have an example on how to do
this?

Here is an example of what my array consists of:

mArray(i,0) = '2007-05-02"
mArray(i,1) = "6:00pm"
mArray(i,2) = "TEXT TEXT TEXT" <------------------ NEED TO DO ALPHA
SORT ON THIS KEY ----------------<<
mArray(i,3) = 6
mArray(i,4) = 4
Put the data into an ad hoc recordset and use its Sort method:

dim rs
Const adDBTimeStamp = 135
Const adVarChar = 200
Const adInteger = 3
set rs=createobject("adodb.recordset")
With rs.Fields
.Append "fDate",adDBTimeStamp
.Append "fTime",adDBTimeStamp
.Append "fText",adVarChar,50
.Append "fNum1",adInteger
.Append "fNum2",adInteger
End With
rs.Open

'loop through the array:
rs.AddNew Array(mArray(i,0),mArray(i,1),mArray(i,2),mArray(i,3), _
mArray(i,4))
'etc.
'end loop
rs.Sort "fText"
 
G

glbdev

Put the data into an ad hoc recordset and use its Sort method:

dim rs
Const adDBTimeStamp = 135
Const adVarChar = 200
Const adInteger = 3
set rs=createobject("adodb.recordset")
With rs.Fields
.Append "fDate",adDBTimeStamp
.Append "fTime",adDBTimeStamp
.Append "fText",adVarChar,50
.Append "fNum1",adInteger
.Append "fNum2",adInteger
End With
rs.Open

'loop through the array:
rs.AddNew Array(mArray(i,0),mArray(i,1),mArray(i,2),mArray(i,3), _
mArray(i,4))
'etc.
'end loop
rs.Sort "fText"

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Thanks BOB ... that worked!!!

- Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,796
Messages
2,569,645
Members
45,367
Latest member
Monarch

Latest Threads

Top