title: Sorting JSON Output in PHP
body: <p>I've got the following JSON:</p>
  
  <pre><code>{
  "row":  [
      {
      "sort":3,
      "type":"fat",
      "widgets":
          [
              {"values": [3,9] },
              {"values": [8,4] }                  
          ]
      },
  {
      "sort":2,
      "type":"three",
      "widgets":
      [
          {"values": [3,4] },
          {"values": [12,7] },
          {"values": [12,7] }                         
      ]
  }                       
  ]
  }
  </code></pre>
  
  <p>And this PHP to output it:</p>
  
  <pre><code>foreach ( $value-&gt;row as $therow )
  {
      echo "&lt;div class='row ".$therow-&gt;type."'&gt;";
  
      foreach ( $therow-&gt;widgets as $thewidgets )
      {
          echo "&lt;div class='widget'&gt;";
          echo $thewidgets-&gt;values[0];
          echo "&lt;/div&gt;";
  
      }
  
      echo "&lt;/div&gt;";
  
  }
  </code></pre>
  
  <p>What I would like to do is sort the ouput based on the sort value in the JSON, any ideas?</p>