title: 400x Sorting Speedup by Switching a.localeCompare(b) to (a<b?-1:(a>b?1:0))
body: <p>By switching a javascript sort function from</p>
  
  <pre><code>myArray.sort(function (a, b) {
    return a.name.localeCompare(b.name);
  });
  </code></pre>
  
  <p>to</p>
  
  <pre><code>myArray.sort(function (a, b) {
    return (a.name &lt; b.name ? -1 : (a.name &gt; b.name ? 1 : 0));
  });
  </code></pre>
  
  <p>I was able to cut the time to sort a ~1700 element array in Chrome from 1993 milliseconds to 5 milliseconds. Almost a 400x speedup. Unfortunately this is at the expense of correctly sorting non-english strings.</p>
  
  <p>Obviously I can't have my UI blocking for 2 seconds when I try to do a sort. Is there anything I can do to avoid the horribly slow localeCompare but still maintain support for localized strings?</p>