Help w/ sorting multi-dimensional array please

Hi all,

I’m making two queries and combining the results into an array and then trying to sort the array based on the timestamp as such:

$r = mysql_query(“SELECT * FROM table1”);

while ($a = mysql_fetch_assoc($r)) {
$fc[$a[‘timestamp’]][‘title’] = …
}

$r = mysql_query(“SELECT * FROM table2”);

while ($a = mysql_fetch_assoc($r)) {
$fc[$a[‘timestamp’]][‘title’] = …
}

So if the final array is something like this:

$fc[1111111111][‘title’] = ‘Dogs’;
$fc[3333333333][‘title’] = ‘Rabbits’;
$fc[2222222222][‘title’] = ‘Cats’;

I want the sorted array to look like this (SORT_DESC by timestamp):

$fc[3333333333][‘title’] = ‘Rabbits’;
$fc[2222222222][‘title’] = ‘Cats’;
$fc[1111111111][‘title’] = ‘Dogs’;

The problem is that array_multisort drops the key if it’s not string.

Any suggestions please?

Thanks

The easiest and most general way would be to just not use keys. Create a custom sort function then call it with usort();
http://ca3.php.net/manual/en/function.usort.php