title: Can you sort/order a PHP FOR loop?
body: <p>Trying to get this awful joomla addon component to work the way the client is asking it to. And I have this for loop in there that loads the results in a bit of a random way. So I'm trying to get it to at least sort in at least 1 specific order. And I believe it needs to be done within the FOR loop. </p>
  
  <p>Here is how the loop is setup:</p>
  
  <pre><code>for ($i = 0; $i &lt; count($vehicle_feature); $i++) {
  </code></pre>
  
  <p>I would like to order it by $fk_featureid. Is it possible within a FOR loop? What would the syntax be?</p>
  
  <p>Thanks!</p>
  
  <p>EDIT: Here is how the array is setup, first each item needs to be grouped together under their category, then I'd like it to sort each item alphabetically under their category:</p>
  
  <pre><code>Array   (   
          [0] =&gt; StdClass Object  (
              [Id] =&gt; 138 
              [Name] =&gt; Controls 
              [Categories] =&gt; Augers &amp; Hydraulics 
              [Published] =&gt; 1 
              [Image_link] =&gt;     )
  
          [1] =&gt; StdClass Object  (
              [Id] =&gt; 122 
              [Name] =&gt; Auger Drives 
              [Categories] =&gt; Augers &amp; Hydraulics 
              [Published] =&gt; 1 
              [Image_link] =&gt;     )
      )
  </code></pre>