Jump to content

Looping through 2-dimensional array based on ascending value of var in dim 2


Recommended Posts

Hi all, hopefully I can explain this correctly

 

I have a 2-dimensional array that I need to loop through. dimension 1 may be something like:

 

array( 1, 2, 3, 4, 5)

 

dimension 2 may be something like

 

array1 (1) = array( john, 947 )

array1 (2) = array( mike, 756 )

array1 (3) = array( jim, 1047 )

array1 (4) = array( chris, 999 )

array1 (5) = array( rick, 111 )

 

I need to loop through it all, but not in the order that array 1 presents everything. I need to go in the order of the numbers in array2's second variable.

 

Ideally I would re-sort array 1 in order of array2's second variable, like so:

 

array1 (1) = array( rick, 111 )

array1 (2) = array( mike, 756 )

array1 (3) = array( john, 947 )

array1 (4) = array( chris, 999 )

array1 (5) = array( jim, 1047 )

 

I hope it makes enough sense for someone to help me out! thanks in advance :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.