tags:

views:

213

answers:

1
+2  A: 

You can use uasort, and inside sortByPubdate define the way the two pubdates should be compared.

uasort($story_array, 'sortByPubdate');
// Sort function
function sortByPubdate($a, $b) {
    if ($a->pubdate == $b->pubdate) {
        return 0;
    }
    return ($a->pubdate < $b->pubdate) ? -1 : 1;
}
Sergi
thanks, it didn't work the content is the same as before, actually the sort(); actually sorted more than the uasort. Is there something else I need to add with uasort am I missing something???? Oh yeah I included it just above the for loop.
NiseNise
Is possible the $story_array is already sorted by date? Just try to order it by a different field (maybe the headline). Also take a look to the documentation http://www.php.net/manual/en/function.uasort.php
Sergi