title: PHP sort a complicated multi-dimensional array by timestamp
body: <p>I have an array as below:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 2
              [type] =&gt; comment
              [batch] =&gt; Array
                      (
                          [0] =&gt; Array
                              (
                                  [id] =&gt; T001
                                  [datetime] =&gt; 2010-05-15 11:29:00
                              )
                          [1] =&gt; Array
                              (
                                  [id] =&gt; T003
                                  [datetime] =&gt; 2010-05-15 11:33:00
                              )
                      )
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 3
              [type] =&gt; status
              [batch] =&gt; Array
                      (
                          [0] =&gt; Array
                              (
                                  [id] =&gt; T002
                                  [datetime] =&gt; 2010-05-15 11:31:00
                              )
                          [1] =&gt; Array
                              (
                                  [id] =&gt; T004
                                  [datetime] =&gt; 2010-05-15 12:32:00
                              )
                          [2] =&gt; Array
                              (
                                  [id] =&gt; T006
                                  [datetime] =&gt; 2010-05-15 12:33:00
                              )
                      )
          )
  
      [2] =&gt; Array
          (
              [id] =&gt; 4
              [type] =&gt; status
              [batch] =&gt; Array
                      (
                          [0] =&gt; Array
                              (
                                  [id] =&gt; T005
                                  [datetime] =&gt; 2010-05-15 12:34:00
                              )
                          [1] =&gt; Array
                              (
                                  [id] =&gt; T007
                                  [datetime] =&gt; 2010-05-15 13:35:00
                              )
                          [2] =&gt; Array
                              (
                                  [id] =&gt; T008
                                  [datetime] =&gt; 2010-05-15 10:36:00
                              )
                      )
          )
  )
  </code></pre>
  
  <p>I would like to re-order the array by <strong>only</strong> the <strong>last datetime</strong> inside the sub array [batch]</p>
  
  <p>the result should be like this:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 4
              [type] =&gt; status
              [batch] =&gt; Array
                      (
                          [0] =&gt; Array
                              (
                                  [id] =&gt; T005
                                  [datetime] =&gt; 2010-05-15 12:34:00
                              )
                          [1] =&gt; Array
                              (
                                  [id] =&gt; T007
                                  [datetime] =&gt; 2010-05-15 13:35:00
                              )
                          [2] =&gt; Array
                              (
                                  [id] =&gt; T008
                                  [datetime] =&gt; 2010-05-15 10:36:00
                              )
                      )
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 2
              [type] =&gt; comment
              [batch] =&gt; Array
                      (
                          [0] =&gt; Array
                              (
                                  [id] =&gt; T001
                                  [datetime] =&gt; 2010-05-15 11:29:00
                              )
                          [1] =&gt; Array
                              (
                                  [id] =&gt; T003
                                  [datetime] =&gt; 2010-05-15 11:33:00
                              )
                      )
          )
  
      [2] =&gt; Array
          (
              [id] =&gt; 3
              [type] =&gt; status
              [batch] =&gt; Array
                      (
                          [0] =&gt; Array
                              (
                                  [id] =&gt; T002
                                  [datetime] =&gt; 2010-05-15 11:31:00
                              )
                          [1] =&gt; Array
                              (
                                  [id] =&gt; T004
                                  [datetime] =&gt; 2010-05-15 12:32:00
                              )
                          [2] =&gt; Array
                              (
                                  [id] =&gt; T006
                                  [datetime] =&gt; 2010-05-15 12:33:00
                              )
                      )
          )
  )
  </code></pre>
  
  <p>Can I do it with "array_multisort"? Please suggest. 
  Thank you very much!</p>