Problem sorting two arrays, both ordered by the first one

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
danf_1979
Forum Commoner
Posts: 72
Joined: Sun Feb 20, 2005 9:46 pm

Problem sorting two arrays, both ordered by the first one

Post by danf_1979 »

Hi again.
I'm working with an array that have the sales in cash for a store and another array that have the names for the salesmen.
I wanted to do a ranking for the cash. So I did a multisort:

Code: Select all

multisort($sales,$salesmen)
thinking I would get the ranked values for the cash and the corresponding salesmen in the other array in the same order of the first array, BUT, I didnt.
I did get the ranked values for the cash, but I got the values for the $salesmen array in alphabetical order! so, I think i cant use multisort. I been reading some sort functions in php.net, but i dont seem to find one that do the job.
Anyone can help?
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

Do any of the cases on this link apply to your case? http://us2.php.net/manual/en/function.a ... tisort.php
danf_1979
Forum Commoner
Posts: 72
Joined: Sun Feb 20, 2005 9:46 pm

Post by danf_1979 »

oh, it was just my mistake in the reading for loop. multisort worked just fine... sorry about this post.
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

That was easy. Maybe next time I can help you. :D
Post Reply