title: JavaScript - Sort SELECT options
body: <p>Using PHP, I scan a directory and list all of the .xml files. Each XML file contains both a "name" element and a "date" element.  The "name" element for each XML file is listed as an option in the select list.  This works perfectly fine, however, the "date" element in each XML file is different and contains a date format like this: mm/dd/yyyy.  What I am trying to figure out how to do is sort the items according to the date, with the earliest date being first one the list and the most recent at the end.</p>
  
  <p>Now say each of those items has a different value for the "date" element.  I need to sort those items with the earliest date being first. I'm not sure how I can store the "date" element data somewhere so that it can be handled by JavaScript.  I'm sorry if this is a very vague description, it's been baffling me for a while and it's a been confusing to try and explain.</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>So right now this is what I have working:</p>
  
  <pre><code>&lt;select name="sel_id" onchange="this.form.submit()" size="20"&gt;
  &lt;option value="item1"&gt;Item 1&lt;/option&gt;
  &lt;option value="item2"&gt;Item 2&lt;/option&gt;
  &lt;option value="item3"&gt;Item 3&lt;/option&gt;
  &lt;option value="item4"&gt;Item 4&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>I guess one thing that would majorly help is knowing if there's a way to store the date somewhere in the  tags besides the value attribute seeing how it's already being used.  The date itself isn't a concern, I have that much figured it, it's just a matter of storing it somewhere so that it can be called client side.</p>