Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
sorting multidimensional arrays
Old 04-23-2005, 11:28 PM sorting multidimensional arrays
Junior Talker

Posts: 1
Trades: 0
I have a set of arrays that looks like this:

$array[1][1]==int
$array[1][2]=="a string"
$array[1][3]=="a string"

$array[2][1]==int
$array[2][2]=="a string"
$array[2][3]=="a string"

$array[3][1]==int
$array[3][2]=="a string"
$array[3][3]=="a string"

$array[4][1]==int
$array[4][2]=="a string"
$array[4][3]=="a string"

$array[5][1]==int
$array[5][2]=="a string"
$array[5][3]=="a string"

and so on until the first dimension reaches 10000. I'm trying to sort $array by int so that $array[1][1] is greater than $array[2][1]. I don't want the strings compared at all; they must stay attached to their int. For example:

$array[1][1]==5052
$array[1][2]=="this is a string attached to 5052!"
$array[1][3]=="this is another string attached to 5052!"

$array[2][1]==1000
$array[2][2]=="this is a string attached to 1000!"
$array[2][3]=="this is another string attached to 1000!"

$array[3][1]==10500
$array[3][2]=="this is a string attached to 10500!"
$array[3][3]=="this is another string attached to 10500!"

$array[4][1]==2000
$array[4][2]=="this is a string attached to 2000!"
$array[4][3]=="this is another string attached to 2000!"

$array[5][1]==2101
$array[5][2]=="this is a string attached to 2101!"
$array[5][3]=="this is another string attached to 2101!"

would become...

$array[1][1]==10500
$array[1][2]=="this is a string attached to 10500!"
$array[1][3]=="this is another string attached to 10500!"

$array[2][1]==5052
$array[2][2]=="this is a string attached to 5052!"
$array[2][3]=="this is another string attached to 5052!"


$array[3][1]==2101
$array[3][2]=="this is a string attached to 2101!"
$array[3][3]=="this is another string attached to 2101!"

$array[4][1]==2000
$array[4][2]=="this is a string attached to 2000!"
$array[4][3]=="this is another string attached to 2000!"

$array[5][1]==1000
$array[5][2]=="this is a string attached to 1000!"
$array[5][3]=="this is another string attached to 1000!"

however I have no idea how to do this. I tried looking at array_multisort, but the article pretty much lost me. can anyone help?
froth is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-26-2006, 01:21 AM Re: sorting multidimensional arrays
Average Talker

Posts: 15
Name: Jeffery Mandrake
Location: San Diego
Trades: 0
That looks suspiciously like a homework assignment!
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

~~~~~~~~~~~~~~~~~~~

Please login or register to view this content. Registration is FREE
cybernewsmaster is offline
Reply With Quote
View Public Profile Visit cybernewsmaster's homepage!
 
Old 06-26-2006, 04:35 PM Re: sorting multidimensional arrays
Charley Delta's Avatar
Experienced Talker

Posts: 32
Location: Rochester, NY USA
Trades: 0
LOL. How do people keep finding these old posts? Froth hasn't been here since posting the question (don't you love how people pepper all the available forums with their question and never show up again to see the answer?), and the URL isn't working.
__________________
Always take into account what nobody would ever do in a million years, because someone will.
Charley Delta is offline
Reply With Quote
View Public Profile
 
Old 06-29-2006, 09:53 PM Re: sorting multidimensional arrays
Novice Talker

Posts: 7
Trades: 0
Lol! The reason he hasn't checked it is probably because he has no time management skills.
__________________

Please login or register to view this content. Registration is FREE
kcraig11388 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to sorting multidimensional arrays
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14698 seconds with 12 queries