How can I make this PHP image file grabbing script sort alpha numerically?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6937869/how-to-sort-array-of-value-by-alpha-bet-in-php-using-asort-function">How to sort array of value by alpha bet in php using asort() function()</a>  </p>
</blockquote>



<p>Basically the script reads images from a directory and then outputs them to html.  So just trying to make this really good script sort images alpha numerically.  Right now it is pretty random in the way it sorts the images.<br>
            

<pre><code>        if ($handle = opendir($dir)) {
        while (false!== ($file = readdir($handle))) {
        sort($file);
        $ext = strrchr($file,".");
        echo "";
        if(in_array($ext,$good_ext))
        {   
        //do something with file
        echo "&lt;img src='images/".$modelname."/slider/".$file."'&gt;";
        }
        else
        {
        echo "bad";
        }
        }
        closedir($handle);
        }
        else
        {
        echo "$dir Directory does not exist!";
        }
        ?&gt;
</code></pre>
