title: sort array based on the indents
body: <p>I have the current array in PHP which is being extracted from a MySQL database (PDO fetch all);</p>
  
  <pre><code>[0] =&gt; Array
      (
          [id] =&gt; 78
          [indent] =&gt; 2.2
          [partnumber] =&gt; OPPN-39-596
          [description] =&gt; BACK WASH NOZZLE - 32 DIA
          [size] =&gt; 
          [rev] =&gt; A
          [code] =&gt; MCH
          [quantity] =&gt; 1
          [total] =&gt; 1
          [notes] =&gt; 
          [partcost] =&gt; 
          [totalcost] =&gt; 
      )
  
  [1] =&gt; Array
      (
          [id] =&gt; 23
          [indent] =&gt; 2.3
          [partnumber] =&gt; OPPN-21-508
          [description] =&gt; FRONT 12MM JET ASSY
          [size] =&gt; 
          [rev] =&gt; A
          [code] =&gt; ASY
          [quantity] =&gt; 3
          [total] =&gt; 3
          [notes] =&gt; 
          [partcost] =&gt; 
          [totalcost] =&gt; 
      )
  
  [2] =&gt; Array
      (
          [id] =&gt; 17
          [indent] =&gt; 2.3.1
          [partnumber] =&gt; OPPN-21-356
          [description] =&gt; INTERNAL CIRCLIP Ø42 BORE S/S
          [size] =&gt; 
          [rev] =&gt; 
          [code] =&gt; HRD
          [quantity] =&gt; 1
          [total] =&gt; 3
          [notes] =&gt; 
          [partcost] =&gt; 
          [totalcost] =&gt; 
      )
  
  [3] =&gt; Array
      (
          [id] =&gt; 26
          [indent] =&gt; 2.3.2
          [partnumber] =&gt; OPPN-21-509
          [description] =&gt; FRONT JET 12MM NOZZLE
          [size] =&gt; 
          [rev] =&gt; A
          [code] =&gt; MCH
          [quantity] =&gt; 1
          [total] =&gt; 3
          [notes] =&gt; 
          [partcost] =&gt; 
          [totalcost] =&gt; 
      )
  
  [4] =&gt; Array
      (
          [id] =&gt; 28
          [indent] =&gt; 2.3.3
          [partnumber] =&gt; OPPN-21-510
          [description] =&gt; FLOW STRAIGHTENER 12MM INSERT 1
          [size] =&gt; 
          [rev] =&gt; A
          [code] =&gt; MCH
          [quantity] =&gt; 1
          [total] =&gt; 3
          [notes] =&gt; 
          [partcost] =&gt; 
          [totalcost] =&gt; 
      )
  
  [5] =&gt; Array
      (
          [id] =&gt; 30
          [indent] =&gt; 2.3.4
          [partnumber] =&gt; OPPN-21-511
          [description] =&gt; FLOW STRAIGHTENER 12MM INSERT 2
          [size] =&gt; 
          [rev] =&gt; A
          [code] =&gt; MCH
          [quantity] =&gt; 1
          [total] =&gt; 3
          [notes] =&gt; 
          [partcost] =&gt; 
          [totalcost] =&gt; 
      )
  
  [6] =&gt; Array
      (
          [id] =&gt; 34
          [indent] =&gt; 2.3.5
          [partnumber] =&gt; OPPN-21-524
          [description] =&gt; O RING 3.53 X 32.92 ID NITRILE
          [size] =&gt; 
          [rev] =&gt; A
          [code] =&gt; HRD
          [quantity] =&gt; 1
          [total] =&gt; 3
          [notes] =&gt; 
          [partcost] =&gt; 
          [totalcost] =&gt; 
      )
  
  [7] =&gt; Array
      (
          [id] =&gt; 76
          [indent] =&gt; 2.4
          [partnumber] =&gt; OPPN-39-592
          [description] =&gt; FRONT 14MM JET ASSY
          [size] =&gt; 
          [rev] =&gt; A
          [code] =&gt; ASY
          [quantity] =&gt; 10
          [total] =&gt; 10
          [notes] =&gt; 
          [partcost] =&gt; 
          [totalcost] =&gt; 
      )
  
  [8] =&gt; Array
      (
          [id] =&gt; 67
          [indent] =&gt; 2.4.1
          [partnumber] =&gt; OPPN-39-581
          [description] =&gt; FRONT JET 14MM NOZZLE
          [size] =&gt; 
          [rev] =&gt; A
          [code] =&gt; MCH
          [quantity] =&gt; 1
          [total] =&gt; 10
          [notes] =&gt; 
          [partcost] =&gt; 
          [totalcost] =&gt; 
      )
  </code></pre>
  
  <p>I need to come up with some code to convert the array to this;</p>
  
  <pre><code>   [0] =&gt; Array
      (
          [id] =&gt; 78
          [indent] =&gt; 2.2
          [partnumber] =&gt; OPPN-39-596
          [description] =&gt; BACK WASH NOZZLE - 32 DIA
          [size] =&gt;
          [rev] =&gt; A
          [code] =&gt; MCH
          [quantity] =&gt; 1
          [total] =&gt; 1
          [notes] =&gt;
          [partcost] =&gt;
          [totalcost] =&gt;
      )
  
  [1] =&gt; Array
      (
          [id] =&gt; 23
          [indent] =&gt; 2.3
          [partnumber] =&gt; OPPN-21-508
          [description] =&gt; FRONT 12MM JET ASSY
          [size] =&gt;
          [rev] =&gt; A
          [code] =&gt; ASY
          [quantity] =&gt; 3
          [total] =&gt; 3
          [notes] =&gt;
          [partcost] =&gt;
          [totalcost] =&gt;
          [0] =&gt; Array
              (
                  [id] =&gt; 17
                  [indent] =&gt; 2.3.1
                  [partnumber] =&gt; OPPN-21-356
                  [description] =&gt; INTERNAL CIRCLIP Ø42 BORE S/S
                  [size] =&gt;
                  [rev] =&gt;
                  [code] =&gt; HRD
                  [quantity] =&gt; 1
                  [total] =&gt; 3
                  [notes] =&gt;
                  [partcost] =&gt;
                  [totalcost] =&gt;
              )
          [1] =&gt; Array
              (
                   [id] =&gt; 26
                   [indent] =&gt; 2.3.2
                   [partnumber] =&gt; OPPN-21-509
                   [description] =&gt; FRONT JET 12MM NOZZLE
                   [size] =&gt;
                   [rev] =&gt; A
                   [code] =&gt; MCH
                   [quantity] =&gt; 1
                   [total] =&gt; 3
                   [notes] =&gt;
                   [partcost] =&gt;
                   [totalcost] =&gt;
                )
          [2] =&gt; Array
                (
                   [id] =&gt; 28
                   [indent] =&gt; 2.3.3
                   [partnumber] =&gt; OPPN-21-510
                   [description] =&gt; FLOW STRAIGHTENER 12MM INSERT 1
                   [size] =&gt;
                   [rev] =&gt; A
                   [code] =&gt; MCH
                   [quantity] =&gt; 1
                   [total] =&gt; 3
                   [notes] =&gt;
                   [partcost] =&gt;
                   [totalcost] =&gt;
                )
          [3] =&gt; Array
                (
                   [id] =&gt; 30
                   [indent] =&gt; 2.3.4
                   [partnumber] =&gt; OPPN-21-511
                   [description] =&gt; FLOW STRAIGHTENER 12MM INSERT 2
                   [size] =&gt;
                   [rev] =&gt; A
                   [code] =&gt; MCH
                   [quantity] =&gt; 1
                   [total] =&gt; 3
                   [notes] =&gt;
                   [partcost] =&gt;
                   [totalcost] =&gt;
                )
          [4] =&gt; Array
                (
                   [id] =&gt; 34
                   [indent] =&gt; 2.3.5
                   [partnumber] =&gt; OPPN-21-524
                   [description] =&gt; O RING 3.53 X 32.92 ID NITRILE
                   [size] =&gt;
                   [rev] =&gt; A
                   [code] =&gt; HRD
                   [quantity] =&gt; 1
                   [total] =&gt; 3
                   [notes] =&gt;
                   [partcost] =&gt;
                   [totalcost] =&gt;
                )
      )
  
  [2] =&gt; Array
      (
          [id] =&gt; 76
          [indent] =&gt; 2.4
          [partnumber] =&gt; OPPN-39-592
          [description] =&gt; FRONT 14MM JET ASSY
          [size] =&gt;
          [rev] =&gt; A
          [code] =&gt; ASY
          [quantity] =&gt; 10
          [total] =&gt; 10
          [notes] =&gt;
          [partcost] =&gt;
          [totalcost] =&gt;
          [0] =&gt; Array
              (
                  [id] =&gt; 67
                  [indent] =&gt; 2.4.1
                  [partnumber] =&gt; OPPN-39-581
                  [description] =&gt; FRONT JET 14MM NOZZLE
                  [size] =&gt;
                  [rev] =&gt; A
                  [code] =&gt; MCH
                  [quantity] =&gt; 1
                  [total] =&gt; 10
                  [notes] =&gt;
                  [partcost] =&gt;
                  [totalcost] =&gt;
              )
      )
  
      [3] =&gt; Array
         (
              [id] =&gt; 76
              [indent] =&gt; 2.5
              [partnumber] =&gt; OPPN-39-592
              [description] =&gt; FRONT 14MM JET ASSY
              [size] =&gt;
              [rev] =&gt; A
              [code] =&gt; ASY
              [quantity] =&gt; 10
              [total] =&gt; 10
              [notes] =&gt;
              [partcost] =&gt;
              [totalcost] =&gt;
         )
  </code></pre>
  
  <p>The array element with an indent of 2.3.1 becomes a child element of the element which has an indent of 2.3 and so on... I need to come up with some code that automatically formats this array to way I need it. I have fighting with multi dimensional for loops all day now but had no luck. Any guidance and assistance would be appreciated. </p>