Help with Array Sorting Please
| From: | Nick Wilson | Date: | Thu, 07 Oct 2004 16:28:37 +0000 |
| Subject: | Help with Array Sorting Please | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-198853@lists.php.net to get a copy of this message | ||
Hi,
If you scroll up the list you'll see another thread of mine, this is
related. The reason for a new thread is that i've made a lot of progress
but the old was getting really confusing..
Here's the scoop:
I have an array like this:
123 => 1 // each value may have few or many duplicate values
321 => 1
543 => 2
432 => 2 // like here, more 2's than 1's see?
566 => 2
568 => 2
999 => 3
878 => 3
444 => 3
Now, the keys are not the issue. What i would really like, is for that
array, to end up like this:
123 => 1
543 => 2
999 => 3
321 => 1
432 => 2
878 => 3
123 => 1
566 => 2
and so on...
The important point here is that it does not matter if a key is repeated
in the resultant array, in fact, that's *good* as long as it starts from
the beggining again when there are no more values = (for example) '1'
With me?
If it helps to understand, each key is an IP address, each value a
Machine number - my job is to never hit the same machine 2x in a row or
the same IP 2x in a row, but to cycle through all the IP's on each
Machine like the example resultant array.
Phew... that was tough to explain, hope it's not a brain twister to
understand ;-)
Many, many thanks..
--
Nick W