title: Sort file list by date
body: <p>With the code below I am generating a list of pdfs located in a directory on my server.  I'd like to have the results sort by date, most recent first oldest last.  </p>
  
  <p>Here it is in action : <a href="http://mt-spacehosting.com/fisheries/plans/northeast-multispecies/" rel="nofollow">http://mt-spacehosting.com/fisheries/plans/northeast-multispecies/</a></p>
  
  <pre><code>&lt;?php 
  $sub = ($_GET['dir']); 
  $path = 'groundfish-meetings/';
  $path = $path . "$sub"; 
  $dh = opendir($path); 
  $i=1; 
  
  while (($file = readdir($dh)) !==   false) { 
      if($file != "." &amp;&amp; $file != "..") { 
          if (substr($file, -4, -3) =="."){
           echo "$i. &lt;option value='" . home_url('/groundfish-meetings/' . $file) .         "'&gt;$file&lt;/option&gt;";
           } $i++; 
          } 
       } closedir($dh); 
  ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Any help would be appreciated.</p>