title: How to sort an array created by the directory_helper in CodeIgniter
body: <p>So I'm using the directory_map function in the Directory Helper and I'm wondering how I can edit that function (or maybe extend it or something) so that it sorts the multidimensional array it gives me.</p>
  
  <p>Here is the array it currently produces;</p>
  
  <pre><code> Array
   (
    [publications] =&gt; Array
      (
          [policy_documents] =&gt; Array
              (
                 [_careers] =&gt; Array
                      (
                          [0] =&gt; careers.pdf
                      )
                  [_background_quality_reports] =&gt; Array
                     (
                          [0] =&gt; industry.pdf
                          [1] =&gt; international.pdf
                          [2] =&gt; departmental_resources.pdf
                          [3] =&gt; contracts.pdf
                          [4] =&gt; research_and_development.pdf
                          [5] =&gt; trade.pdf
                      )
                  [_pre_release_access_list] =&gt; Array
                      (
                          [0] =&gt; pre_release_access_list.pdf
                      )
              )
          [people] =&gt; Array
              (
                  [health] =&gt; Array
                      (
                          [very_serious_injuries] =&gt; Array
                              (
                                [_1_january_2013] =&gt; Array
                                      (
                                          [0] =&gt; 1_january_2013.pdf
                                      )
                              )
                      )
                  [military] =&gt; Array
                      (
                          [quarterly_manning_report] =&gt; Array
                              (
                                  [_1_january_2013] =&gt; Array
                                     (
                                          [0] =&gt; 1_january_2013.pdf
                                      )
                              )
                          [monthly_manning_report] =&gt; Array
                              (
                                 [_20110201_1_february_2011] =&gt; Array
                                      (
                                          [0] =&gt; 1_february_2011.xls
                                          [1] =&gt; key_points.html
                                          [2] =&gt; 1_february_2011.pdf
                                      )
                                  [_20110301_1_march_2011] =&gt; Array
                                      (
                                          [0] =&gt; 1 March 2011.pdf
                                      )
                                  [_20110501_1_may_2011] =&gt; Array
                                      (
                                          [0] =&gt; 1 May 2011.pdf
                                      )
                                  [_20110401_1_april_2011] =&gt; Array
                                      (
                                          [0] =&gt; 1 April 2011.pdf
                                      )
                              )
                      )
                  [civilian] =&gt; Array
                      (
                          [civilian_personnel_report] =&gt; Array
                              (
                                  [_1_april_2012] =&gt; Array
                                      (
                                          [0] =&gt; 1_april_2012.pdf
                                      )
                                  [_1_october_2012] =&gt; Array
                                      (
                                         [0] =&gt; 1_october_2012.pdf
                                      )
                                  [_1_january_2013] =&gt; Array
                                      (
                                          [0] =&gt; 1_january_2013.pdf
                                          [1] =&gt; key_points.html
                                      )
                                  [_1_july_2012] =&gt; Array
                                      (
                                          [0] =&gt; 1_july 2012.pdf
                                      )
                              )
                      )
                  [search_and_rescue] =&gt; Array
                      (
                          [monthly] =&gt; Array
                              (
                                  [_1_February_2013] =&gt; Array
                                      (
                                          [0] =&gt; 1_february_2013.pdf
                                      )
                              )
                          [annual] =&gt; Array
                              (
                                  [_2012] =&gt; Array
                                      (
                                          [0] =&gt; 2012.pdf
                                      )
                              )
                          [quarterly] =&gt; Array
                              (
                                  [_q3_2012] =&gt; Array
                                      (
                                          [0] =&gt; q3_2012.pdf
                                      )
                              )
                      )
              )
          [estate] =&gt; Array
              (
              )
      )
  )
  </code></pre>
  
  <p>That's a little messy but you get the idea. Any attempt to wrap a sort() or an asort() around the variable in my model leads to an error. Which is why I think I might have to edit this function or maybe create me a new one...</p>