68336937f10f23050e3ba3b52056c361fb815a8a
tdreszer
  Tue Dec 20 15:45:22 2011 -0800
Substantial speed up of long table sort.  IE needs every bit of help it can get.
diff --git src/hg/js/utils.js src/hg/js/utils.js
index af81020..f947586 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -1350,34 +1350,32 @@
 
         // Create array of the primary sort column's text
         var cols = new Array();
         var trs = tbody.rows;
         $(trs).each(function(ix) {
             var th = this.cells[sortColumns.cellIxs[0]];
             if(sortColumns.useAbbr[0])
                 cols.push(new sortTable.field(th.abbr,sortColumns.reverse[0],this));
             else
                 cols.push(new sortTable.field($(th).text(),sortColumns.reverse[0],this));
         });
 
         // Sort the array
         cols.sort(sortTable.fieldCmp);
 
-        var topIndex = tbody.rows[0].rowIndex; // This could vary depending upon header rows
-        for(var cIx=cols.length-1;cIx>=0;cIx--) {
-            if (cols[cIx].row.rowIndex > topIndex) // Inserting before onesself will delete row
-                $( cols[cIx].row ).insertBefore( tbody.rows[0] );
+        for(var cIx=0;cIx<cols.length;cIx++) {
+            tbody.appendChild(cols[cIx].row);
         }
 
         sortTable.tbody=tbody;
         sortTable.columns=sortColumns;
         setTimeout('sortTable.sortFinish(sortTable.tbody,sortTable.columns)',5); // Avoid javascript timeouts!
     },
 
     sortFinish: function (tbody,sortColumns)
     {// Additional sort cleanup.
     // This is in a separate function to allow calling with setTimeout() which will prevent javascript timeouts (I hope)
         sortTable.savePositions(tbody);
         if ($(tbody).hasClass('altColors'))
             sortTable.alternateColors(tbody,sortColumns);
         $(tbody).parents("table.tableWithDragAndDrop").each(function (ix) {
             tableDragAndDropRegister(this);