Page 1 of 1

Sorting By Value

Posted: Mon May 16, 2005 4:09 pm
by Pineriver
How can I have a multidimential array sorted by value, not by key..

Code: Select all

#Sample code that I have already, making up the array.
while($i<10){
$people[$address][$i]=$unix_date;
$i++;
}
I am trying to sort through a text based log file where there are 2 fields, a unix time stamp and the address of a person.
The array is unique to each persons address but that person has multi counts of events which is recorded as a unix timestamp.

Code: Select all

[Address1] => Array
(
[19] => 1116263520
[20] => 1116263537
[22] => 1116265745
[23] => 1116265770
)

[Address2] => Array
(
[2] => 1116217275
[3] => 1116218023
[8] => 1116218035
[5] => 1116218076
[44] => 1116218087
)


I would like to have the final array sorted where the addresse's dates are sorted from first to the latest. So say if Address1 has the newest unix date that would come first in the array.
I almost figured this out but then I have a loop looping through the array that has to get the dates and addresses :x
Tell me if this makes sence and you can figure it out.

Posted: Thu Jun 09, 2005 11:06 am
by anjanesh
Have you tried using array_flip ?