473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Alpha multidimensional array sort

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

May 25 '07 #1
2 4775
gl****@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"
May 25 '07 #2
On May 25, 2:27 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
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

May 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brian | last post by:
I have an array like this: $events = array( array( '2003-07-01', 'Event Title 1', '1' //ID Number (not unique) ), array( '2003-07-02',
2
by: markus | last post by:
I usually store info in arrays using field names $array='Germany', $array="GE"; $array='United Sates" $array="US"; $array='France" $array='FR"
7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
3
by: success_ny | last post by:
Does anyone have a code snippet to compare those values so I can sort the array of alpha-numeric values that include both characters and integers in it? I.e., if we have values like 4236 and...
9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
11
by: Joshua Russell | last post by:
Hi, I wish to parse an XML file into some sort or array or multidimensional storage. The XML file is as follows (without any parent tags just to give you an idea of the structure)... <Ship...
1
by: Mark Smith | last post by:
I'm trying to copy data from a 1D array to a 2D array. The obvious thing doesn't work: int twoDee = new int; int oneDee = new int { 1, 2 }; Array.Copy(oneDee, 2, twoDee, 2, 2); This causes a...
16
by: Rehceb Rotkiv | last post by:
Hello everyone, can I sort a multidimensional array in Python by multiple sort keys? A litte code sample would be nice! Thx, Rehceb
9
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.