multidimensional array sorting
| From: | Kelly Protsko | Date: | Sat, 19 Apr 2003 15:58:01 +0000 |
| Subject: | multidimensional array sorting | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-144482@lists.php.net to get a copy of this message | ||
I am trying to sort a multidimensional array but it doesn't seem to do
anything. I have an array that stores the dates broken up into
month,day, year format. And I want to sort the array based on the day.
This is the way I was trying to do the sort. I am trying to compare
the second elements in the lines to sort the array. For some reason it
doesn't change the order of the array at all. Am I missing a step
here?
usort($lines,compare);
function compare($x,$y)
{
If ($x[1] == $y[1])
return 0;
else If ($x[1] < $y[1])
return -1;
else
return 1;
}
Kelly