What's the difference between array.sort() and array.sort(function(a,b) { return a - b; })?
<p>I have a piece of code which triggers some actions. Before that it simply sorts weights. Everything works well when I use: <code>weight.sort()</code> where <code>weight</code> is an non-empty array e.g. <code>[10 20 30 40]</code>, but when I change that to:</p>

<pre><code>weight.sort(function(a,b) {
    return a - b;
});
</code></pre>

<p>one of the actions has no effect (display a div). Being honest I don't know what might cause the difference. It seems strange to me because <code>weight</code> is the same after sorting with both methods and clearly changing that piece of code makes my script working or not. There are no errors in FireBug.</p>
