title: Order multidimensional array recursively at each level in PHP
body: <p>I have an array of this form:</p>
  
  <pre><code>Array
  (
      [first_level] =&gt; Array
          (
              [dir_3] =&gt; Array
                  (
                      [subdir_1] =&gt; Array
                          (
                              [file_2.mp4] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_2.mp4
                                  )
  
                              [file_1.mp4] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_1.mp4
                                  )
  
                          )
                  )
              [dir_1] =&gt; Array
                  (
                      [subdir_2] =&gt; Array
                          (
                              [file_6.mp4] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_6.mp4
                                  )
                              [file_9.mp4] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_9.mp4
                                  )
                              [file_7.mp4] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_7.mp4
                                  )
                          )
                      [subdir_1] =&gt; Array
                          (
                              [file_8] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_8.mp4
                                  )
  
                          )
          )
      )
  )
  </code></pre>
  
  <p>I need to order it like this:</p>
  
  <pre><code>Array
  (
      [first_level] =&gt; Array
          (
              [dir_1] =&gt; Array
                  (
                      [subdir_1] =&gt; Array
                          (
                              [file_8] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_8.mp4
                                  )
                          )
                      [subdir_2] =&gt; Array
                          (
                              [file_6.mp4] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_6.mp4
                                  )
                              [file_7.mp4] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_7.mp4
                                  )
                              [file_9.mp4] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_9.mp4
                                  )
                          )
          )
          [dir_3] =&gt; Array
                  (
                      [subdir_1] =&gt; Array
                          (
                              [file_1.mp4] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_1.mp4
                                  )
  
                              [file_2.mp4] =&gt; stdClass Object
                                  (
                                      [name] =&gt; file_2.mp4
                                  )
  
                          )
                  )
      )
  )
  </code></pre>
  
  <p>I browsed through other similar questions, and I've been trying to solve it with <a href="http://au2.php.net/manual/en/function.usort.php" rel="noreferrer">usort</a> but I couldn't get my head around it. :S</p>
  
  <p>Any idea?               </p>