I have a form where I want people to put in their year of birth. You can only apply if you are over 18 so in the year of birth field I want the min age to be 18. I have done this as shown below however I want to sort the numbers from latest year at the top and oldest year at the bottom. currently I show 1913 first, but I want to show 1994 first. Here is my code

```
<div id="my-container"></div>

<script>
      var d = new Date();
      var y = d.getFullYear();
      var selectList = "<select>";
      for (var x = (y-100); x < (y - 18); x++) {
          selectList += "<option>" + x + "</option>";
      }
      selectList += "</select>";
      $('#my-container').html(selectList);
      </script>

```
['https://Stackoverflow.com/questions/15126798', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/737114/']
As [Nile mentioned](https://stackoverflow.com/questions/15126798/js-for-loop-sort-numbers/15126843#comment21290540_15126798),

```
var d = new Date();
var y = d.getFullYear();
var selectList = "<select>";
for (var x = y-18; x >= y-100; x--) {
    selectList += "<option>" + x + "</option>";
}
selectList += "</select>";
$('#my-container').html(selectList);

```

<http://jsfiddle.net/samliew/WzwKw/>
try this

```
 <script>
  var d = new Date();
  var y = d.getFullYear();
  var selectList = "<select>";
  for (var x = y-18; x > y - 100; x--) {
      selectList += "<option>" + x + "</option>";
  }
  selectList += "</select>";
  $('#my-container').html(selectList);
  </script>

```