what is the best way to customize the order of directory list using scandir
<pre><code>$dir    = $_SERVER['DOCUMENT_ROOT'] . '/images/myfav/';
$dirFiles = scandir($dir);
foreach ( $dirFiles as $k =&gt; $v)
{   
    if (is_dir($dir . "/" . $v) &amp;&amp; $v != '.' &amp;&amp; $v != '..' )
    {
        if ( ($files = @scandir($dir . "/" . $v)) &amp;&amp; (count($files) &gt; 2) )  
        {  
            $link = strtolower(str_replace(' ','-',$v));
            echo '&lt;a href="/myfav/' . $link . '" title="' . $v . '"';
            if ($_GET['subpage'] == $link) echo ' class="selected"';
            echo '&gt;&lt;span&gt;' . $v . '&lt;/span&gt;&lt;/a&gt;';    
        }  
    }
}
</code></pre>

<p>I am listing the directories by using above script, now there is one requirement came up that I need to dislay these directories in customized order. Some have the priority and should display before others.</p>

<p>What is the best way to impliment this.</p>

<p>One way which I think could be adding digit in front of each directory according to the order and using script split the digit and perform some sort of order. </p>

<p>However othe way could be define the array in the script with the exact directory names and order digit, and based upone this we can scan the director and somehow mactch the order of in the existing array in script? </p>
