Page 1 of 1

Problem sorting two arrays, both ordered by the first one

Posted: Thu Mar 03, 2005 1:45 pm
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?

Posted: Thu Mar 03, 2005 2:15 pm
by smpdawg
Do any of the cases on this link apply to your case? http://us2.php.net/manual/en/function.a ... tisort.php

Posted: Thu Mar 03, 2005 3:06 pm
by danf_1979
oh, it was just my mistake in the reading for loop. multisort worked just fine... sorry about this post.

Posted: Thu Mar 03, 2005 3:09 pm
by smpdawg
That was easy. Maybe next time I can help you. :D