title: Sort foreach loop result
body: <p>I want to sort it by $distance base in foreach loop in my VIEWS.. so heres my code in Models</p>
  
  <pre><code>    $db = $this-&gt;getDbo();
      $query = $db-&gt;getQuery(true)
                  -&gt;select('*')
                  -&gt;from('#__load');
  
      $db-&gt;setQuery($query);               
      $db-&gt;query();
      $rows = $db-&gt;loadObjectList();
      return $db-&gt;loadObjectList();
  
  </code></pre>
  
  <p>This is the code in my View where i want to sort it by distance</p>
  
  <pre><code>  foreach ($this-&gt;items as $i =&gt; $item) {  
         $distance = $item-&gt;result1 * $item-&gt;result2        
    sort($distance)
  }
  
  echo $distance
  </code></pre>
  
  <p>result</p>
  
  <blockquote>
    <p>3, 6, 2, 7, 8</p>
  </blockquote>
  
  <p>i want to show like this</p>
  
  <blockquote>
    <p>2, 3, 6, 7, 8 </p>
  </blockquote>