title: How do I Custom Sort a Multidimensional Array in PHP (codeingiter)
body: <p>i have an array like:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [category_id] =&gt; 411
              [category_name] =&gt; some text
              [data] =&gt; Array
                  (
                      [1] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91689
                              [name] =&gt; some text                            
                              [pubDate] =&gt; December 23, 2019
                          )
  
                      [0] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91670
                              [name] =&gt; some text                           
                              [pubDate] =&gt; November 23, 2019
                          )
  
                  )
  
          )
  
      [1] =&gt; Array
          (
              [category_id] =&gt; 15755
              [category_name] =&gt; some text
              [data] =&gt; Array
                  (
                      [1] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 93624
                              [name] =&gt; some text                           
                              [pubDate] =&gt; January 02, 2019
                          )
  
                      [0] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 93621
                              [name] =&gt; some text                            
                              [pubDate] =&gt; January 02, 2019
                          )
  
                  )
  
          )
  
      [2] =&gt; Array
          (
              [category_id] =&gt; 15879
              [category_name] =&gt; some text
              [data] =&gt; Array
                  (
                      [0] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91683
                              [name] =&gt; some text                          
                              [pubDate] =&gt; December 31, 2019
                          )
  
                  )
  
          )
  
      [3] =&gt; Array
          (
              [category_id] =&gt; 456
              [category_name] =&gt; some text
              [data] =&gt; Array
                  (
                      [3] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 93675
                              [name] =&gt; some text                           
                              [pubDate] =&gt; January 03, 2019
                          )
  
                      [2] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91679
                              [name] =&gt; some text
                              [pubDate] =&gt; November 23, 2019
                          )
  
                      [1] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91675
                              [name] =&gt; some text
                              [pubDate] =&gt; November 23, 2019
                          )
  
                      [0] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91667
                              [name] =&gt; some text
                              [pubDate] =&gt; November 23, 2019
                          )
  
                  )
  
          )
  
      [4] =&gt; Array
          (
              [category_id] =&gt; 435
              [category_name] =&gt; some text
              [data] =&gt; Array
                  (
                      [2] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 93552
                              [name] =&gt; some text
                              [pubDate] =&gt; December 31, 2019
                          )
  
                      [1] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91685
                              [name] =&gt;some text
                              [pubDate] =&gt; November 23, 2019
                          )
  
                      [0] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91677
                              [name] =&gt; some text
                              [pubDate] =&gt; November 23, 2019
                          )
  
                  )
  
          )
  
  )
  </code></pre>
  
  <p>and i want like this :</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [category_id] =&gt; 411
              [category_name] =&gt; some text
              [data] =&gt; Array
                  (
                      [1] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91689
                              [name] =&gt; some text                            
                              [pubDate] =&gt; December 23, 2019
                          )
  
                      [0] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91670
                              [name] =&gt; some text                           
                              [pubDate] =&gt; November 23, 2019
                          )
  
                  )
  
          )
  
      [1] =&gt; Array
          (
              [category_id] =&gt; 15755
              [category_name] =&gt; some text
              [data] =&gt; Array
                  (
                      [1] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 93624
                              [name] =&gt; some text                           
                              [pubDate] =&gt; January 02, 2019
                          )
  
                      [0] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 93621
                              [name] =&gt; some text                            
                              [pubDate] =&gt; January 02, 2019
                          )
  
                  )
  
          )
  
      [2] =&gt; Array
          (
              [category_id] =&gt; 15879
              [category_name] =&gt; some text
              [data] =&gt; Array
                  (
                      [0] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91683
                              [name] =&gt; some text                          
                              [pubDate] =&gt; December 31, 2019
                          )
  
                  )
  
          )
  
      [3] =&gt; Array
          (
              [category_id] =&gt; 456
              [category_name] =&gt; some text
              [data] =&gt; Array
                  (
                      [3] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 93675
                              [name] =&gt; some text                           
                              [pubDate] =&gt; January 03, 2019
                          )
  
                      [2] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91679
                              [name] =&gt; some text
                              [pubDate] =&gt; November 23, 2019
                          )
  
                      [1] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91667
                              [name] =&gt; some text
                              [pubDate] =&gt; November 23, 2019
                          )
  
                      [0] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91675
                              [name] =&gt; some text
                              [pubDate] =&gt; November 23, 2019
                          )
  
                  )
  
          )
  
      [4] =&gt; Array
          (
              [category_id] =&gt; 435
              [category_name] =&gt; some text
              [data] =&gt; Array
                  (
                      [2] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91685
                              [name] =&gt; some text
                              [pubDate] =&gt; December 31, 2019
                          )
  
                      [1] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 91677
                              [name] =&gt;some text
                              [pubDate] =&gt; November 23, 2019
                          )
  
                      [0] =&gt; stdClass Object
                          (
                              [album_id] =&gt; 93552
                              [name] =&gt; some text
                              [pubDate] =&gt; November 23, 2019
                          )
  
                  )
  
          )
  
  )
  </code></pre>
  
  <p>Please help!
  Thanks!</p>