             layeringMode = ITEM_ORDERED_LAYERING; 
     }
     
-    /**
-     *  @private
-     * 
-     *  A simple insertion sort.  This works well for small lists (under 12 or so), uses
-     *  no aditional memory, and most importantly, is stable, meaning items with comparable
-     *  values will stay in the same order relative to each other. For layering, we guarantee
-     *  first the layer property, and then the item order, so a stable sort is important (and the 
-     *  built in flash sort is not stable).
-     */
-    private static function sortOnLayer(a:Vector.<IVisualElement>):void
-    {
-        var len:Number = a.length;
-        var tmp:IVisualElement;
-        if (len<= 1)
-            return;
-        for (var i:int = 1;i<len;i++)
-        {
-            for (var j:int = i;j > 0;j--)
-            {
-                if ( a[j].layer < a[j-1].layer )
-                {
-                    tmp = a[j];
-                    a[j] = a[j-1];
-                    a[j-1] = tmp;
-                }
-                else
-                    break;
-            }
-        }
-    }
-
+ 
     /**
      *  @private
      */

            mergeData.insertIndex = 0;

            //bottomLayerItems.sortOn("layer",Array.NUMERIC);
            sortOnLayer(bottomLayerItems);
            len = bottomLayerItems.length;

            for (i=0;i<len;i++)

        {
            keepLayeringEnabled = true;
            //topLayerItems.sortOn("layer",Array.NUMERIC);
            GroupBase.mx_internal::sortOnLayer(topLayerItems);
            len = topLayerItems.length;
            for (i=0;i<len;i++)
            {
