Javascript sort not working with IE9?
<p>the problem is I have a list with contacts and when someone change his/her status I try to move them to the top of the list. Everything worked till now, with IE9, and Firefox 4 is not working. I show you the code:</p>

<pre><code>function sortByStatus()
{

  var divs = getElementsByClassName(document,"status_sort");
  divs.sort(compare);

  for (var i = 0; i &lt; divs.length; i++)
  {
    $("#contact_info").append(divs[i]);
  }
}

function compare(div1, div2)
{
  var id1 = div1.getAttribute("id");
  var id2 = div2.getAttribute("id");
  if (id1 &gt; id2)
    return 1;
  else if (id1 &lt; id2)
    return -1;
  else
    return 0;
}
</code></pre>

<p>Any idea or possible fix? Thank you.</p>

<p><strong>update</strong></p>

<p>I have tried MrBuuBuu solution and it works patially, because now the sort by status works but the alphabetic sort is not working. I had to change part of MrBuuBuu solution, the compare function, because I compare the name of the contacts with a number just before the name that represent the status (ex. 2John , 2 means offline, and 1 online) so I have to compare with '&lt;' and '>' and return 1, -1 or 0.</p>

<p>But what is worst, now it doesn't work with IE7 or IE8... the sort by status is not working.</p>

<p>Really weird, any idea?</p>
