title: Custom sorting function bottleneck
body: <p>I am trying to sort big array using actionscript 3.</p>
  
  <p>The problem is that i have to use custom sorting function which is painfully slow and leads to flash plugin crash.</p>
  
  <p>Below is a sample code for custom function used to sort array by length of its members:</p>
  
  <pre><code>            private function sortByLength():int {
                  var x:int = arguments[0].length;
                  var y:int = arguments[1].length;
                  if (x &gt; y){
                      return 1;                       
                  }else if (x &lt; y){
                      return -1;
                  }else{
                      return 0;
                  }
               }
  </code></pre>
  
  <p>Which is called like this:</p>
  
  <pre><code>    var txt:Array = ["abcde","ab","abc","a"];
      txt.sort(sortByLength);
  </code></pre>
  
  <hr>
  
  <p>Please advise me how can this be done faster ?</p>
  
  <p>How to change application logic to avoid Flash plugin crashes during sorting ?</p>