Hi,
I have an array or objects with a dates which I wish to sort by.
I have the following custom function that I pass to usort
function sortMonths($a, $b) {
if ( $a->received_date == $b->received_date ) return 0;
return ($a->received_date > $b->received_date) ? 1 : -1;
}
Which does as required and sorts dates so I get:
2009-05-01 2009-03-01 2008-05-01 2008-03-01 2007-03-01
However how do I group together by months then order by the year to obtain:
2009-05-01 2008-05-01 2009-03-01 2008-03-01 2007-03-01
Thanks