title: Sort on array inside mysql_fetch_array
body: <p>I've a little PHP script that get results from my database. In the <code>mysql_fetch_array()</code> I count files on the server in a folder. I get the folder name of the MySQL results.</p>
  
  <p>What I want is to build a list with all companynames and a total of all the files from the associated folder.</p>
  
  <p>Well, so far so good. But the problem is I want to sort the list on the total of files.</p>
  
  <p>My script look like this:</p>
  
  <pre><code>&lt;? $query = "SELECT * FROM users WHERE id = '".$_COOKIE['users_id']."'"; $sql = mysql_query("$query");
  while ($fill = mysql_fetch_array($sql)) { 
     $multi_user = $fill['multi_user'];
     $folder = $fill['folder'];
     $company_name = $fill['company_name'];
  
     $directory_purchase = '/var/www/vhosts/domain.nl/private/'.$folder.'/purchase/';
     $directory_sales = '/var/www/vhosts/domain.nl/private/'.$folder.'/sales/';
     $email_folder = '/var/www/vhosts/domain.nl/private/'.$folder.'/email/';
     $kas_folder = '/var/www/vhosts/domain.nl/private/'.$folder.'/bank/';
     $multi_folder = '/var/www/vhosts/domain.nl/private/'.$folder.'/multi/';
  
     $total_purchase = count(glob($directory_purchase."*.*"));
     $total_sales = count(glob($directory_sales."*.*"));
     $total_email = count(glob($email_folder."*.*"));
     $total_kas = count(glob($kas_folder."*.*"));
     $total_multi = count(glob($multi_folder."*.*"));
  
     $total = $total_purchase + $total_sales + $total_email + $total_kas + $total_multi;
  
     echo '&lt;table&gt;
       &lt;tr&gt;
           &lt;td&gt;'. $company_name. '&lt;/td&gt;
           &lt;td&gt;'. $total .'&lt;/td&gt;
       &lt;/tr&gt;
     &lt;/table&gt;';
  }?&gt;
  </code></pre>
  
  <p>Somebody know how to do this?</p>