title: Sorting selections alphabetically
body: <p>I am wondering how to sort select options alphabetically. I was reading on another page where you can jQuery and I completely get the hang of it, I'm just confused a tad bit how I'd use it on the code I use for my selecting.</p>
  
  <p>Here's my selection code:</p>
  
  <pre><code>&lt;select class="form-control" id="rareImage" name="rareImage"&gt;
  &lt;?php
      if($open = opendir(ROOT .'/resources/images/small_furni')) {
          while(false != ($file = readdir($open))) {
              if($file == '.' || $file == '..') {
                  continue;
              }
              echo '&lt;option value="'. $file .'" '. ((isset($rareimage) &amp;&amp; $rareimage == $file) ? 'selected' : '') .'&gt;'. $file .'&lt;/option&gt;';
          }
      }
  ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>The other page suggested giving it a option value and then using jQuery to sort it. But like I said, I'm kind of confused how I'd go about using it on this code. Basically, the above code outputs a list of images to select from, but they're not in alphabetical order.</p>
  
  <p>Reference I used: <a href="http://jsfiddle.net/3YjNR/2/" rel="nofollow">http://jsfiddle.net/3YjNR/2/</a></p>