Alpha multidimensional array sort

Alpha multidimensional array sort

am 25.05.2007 19:55:33 von 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

Re: Alpha multidimensional array sort

am 25.05.2007 20:27:20 von reb01501

glbdev@gmail.com wrote:
> 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"

--
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"

Re: Alpha multidimensional array sort

am 26.05.2007 00:17:15 von glbdev

On May 25, 2:27 pm, "Bob Barrows [MVP]"
wrote:
> glb...@gmail.com wrote:
> > 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"
>
> --
> 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