php - How to sort two fields in an array in cakePHP? -


i'm working on cakephp. have array

     array (     [0] => array         (             [event] => array                 (                      [start_date] => 2014-01-23                      [year] => 2014                 )         )      [1] => array         (             [event] => array                 (                      [start_date] => 2015-01-23                     [year] => 2015                 )         )      [2] => array         (             [event] => array                 (                      [start_date] => 2015-02-23                      [year] => 2015                 )         )      [3] => array         (             [event] => array                 (                       [start_date] => 2016-02-01                     [year] => 2016                 )         )      [4] => array         (             [event] => array                 (                     [start_date] => 2016-02-02                     [year] => 2016                 )         ) ) 

i want array asc on start_date, want sort year desc. have done

 $history = set::sort($eventsortedhistory, '{n}.event.start_date', 'asc');      $history = set::sort($eventsortedhistory, '{n}.event.year', 'desc'); 

obviously, sort year.

so,how can sort year desc , start_date asc in php?

i think might looking array_multisort() php function.

if want use set::sort need create custom function achieve because isn't meant sort arrays multiple fields.

solved issue array_multisort()

hope helps :)


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -