Search code examples
phpsortingasort

How to sort an array by date it was created


I have an array of articles.

 $allarticles = Array ([0] => Array ([id] => 24,
                                     [article_id] => 74,
                                     [created] => 2011-01-01 20:48:48 ) 
                       [1] => Array ( [id] => 39,
                                      [article_id] => 94,
                                      [created] => 2011-02-21 21:06:44 ) 
                      );     

I would like to sort the array by the created date(DESC most recent first).

I appreciate any help.

Thanks.


Solution

  • You might be able to use the CakePHP static Set::sort method here.