×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

multi array sort

multi array sort

multi array sort

(OP)
I have this:
        v(0, 0) = 4
        v(0, 1) = 100
        v(1, 0) = 5
        v(1, 1) = 800
        v(2, 0) = 2
        v(2, 1) = 200
        v(3, 0) = 6
        v(3, 1) = 50
        v(4, 0) = 1
        v(4, 1) = 550

And I want this:
v(0,0)= 1
v(0,1)=550
v(1,0)= 2
v(1,1)=200
v(2,0)= 4
v(2,1)=100
v(3,0) = 5
v(3,1)=800
v(4,0) = 6
v(4,1)=50

How can I code it?
Replies continue below

Recommended for you

RE: multi array sort

Dear Enque,

Your problem is to sort a group of records, on the value of a particular column.

I do not know what your program exactly does, but I think it collects multiple sets of related data, and analyzes them.  In order to solve this type of problems systematically, you need to understand any (or both) of the two following concepts.

1. User-defined data-structures
2. Database

These topics are a bit elaborate, so cannot be explained here.  But, these are explained in any intermediate-level VB book.

I could send an example code for solving this, but for some reason I consider that pointless, without explaining the concept.

Regards

Yeasir Rahul

Principal, VoltSmith Technologies
www.voltsmith.com

RE: multi array sort

Personally I would use VB to create an Access database with your table in it and then use the Jet functionality to do the sorting. It may not sound efficient but computers are fast and the functionality for sorting that a database gives is worth it. And using a db you get and filtering and storing between sessions and much more.

RE: multi array sort

Hi, You could use a collection object, where the number 1,2,3,etc is converted into a string and used as the key, the larger number is used as the value.

e.g.

Dim ccol As Collection
Set ccol = New Collection
' note that the order that the data is entered is unimportant
ccol.Add Key:=Str(2), Item:=200
ccol.Add Key:=Str(1), Item:=550
' ...

Debug.Print ccol(Str(1))
Debug.Print ccol(Str(2))
' ...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close