title: Why does't the following Javascript sort code work?
body: <p>I am using jquery to extract text of a set of elements into an array and want to sort them after inserting an element into the array. However, the sort is not working (as in the array remains in the same order after the sort). What's wrong? Code excerpt is below:</p>
  
  <pre><code>var sortedList = [];
  $("div.resource").each(function(i, item) {
      var resource = $(this).html().toLowerCase();
      sortedList.push(resource);
  })
  
  // Add the new item 
  sortedList.push(resource_name.toLowerCase());
  
  alert("before sort");
  for (var i = 0; i &lt; sortedList.length; i++) {
      alert(sortedList[i]);
  }
  
  // Sort the list
  sorted = sortedList.sort();
  
  alert("after sort");
  for (var i = 0; i &lt; sorted.length; i++) {
      alert(sorted[i]);
  }
  </code></pre>