Sorting multi-dimensional arrays

I can sort an array using the arraysort function but I can only sort one dimension at a time. How can I sort two rows of my array in parallel such that only the first row is sorted by its content and the second is sorted according to the changes in the first row?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you give an example of what you are trying to do, what the sample array would look like, and what the desired result would be?  Thanks.

:) dapperry
yeah... need an example/illustration of this.

For this approach, you may want to write your own "sort" tag.

If I understand what you're asking, consider using a "3rd" array as and "index" array.  The 3rd array field values are used as "index numbers" for your 1st and 2nd arrays.  First, add numbers (in ascending order) to the "3rd" array fields.  When sorting by the "first" column, merely change the location of the 3rd arrays field values (don't change the positions of the fields in the 1st and 2nd array!!).  After the sort, the location of the 3rd array field values represent to sort, which can be used as indexs to the 1st and 2nd field contents.

Again, you may have to write your own sorter for this one (sort tag), which augments the function of sorting indexs.

Good Luck.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.