Sorting an multidimensional array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
skallagrimur
Forum Newbie
Posts: 9
Joined: Fri Nov 12, 2010 4:33 am

Sorting an multidimensional array

Post by skallagrimur »

Hello,

I got a 2-dimensional array. I'm trying to sort it. Say I have:
MyArrays[j][k], where j={0,1,..,n} and k={0,1,..,n}.

Is it difficult to explain to me how I would go about sorting by say the k=3 array.
I hope I am making myself clear.

All help appreciated. Thanks.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Sorting an multidimensional array

Post by requinix »

You can use array_multisort or usort. One of those will probably make more sense to you than the other.
Post Reply