/**
*表格排序
*t:表格体.例:myTable.tBodies[0]
*iRowEnd:第几行停止排序.例:myTable.tBodies[0].rows.length-1
*fReverse:升序,降序.例:true(升)false(降)
*iColumn:第几列需要排序.例 4
*/
function insertionSort(t, iRowEnd, fReverse, iColumn)
{
  var iRowInsertRow, iRowWalkRow, current, insert;  for ( iRowInsert = 0 + 1 ; iRowInsert <= iRowEnd ; iRowInsert++ )
  {
    if (iColumn)
    {
      if( typeof(t.children[iRowInsert].children[iColumn]) != "undefined")
        textRowInsert = t.children[iRowInsert].children[iColumn].innerText;
      else
        textRowInsert = "";
    }
    else
    {
      textRowInsert = t.children[iRowInsert].innerText;
    }
        
    for ( iRowWalk = 0; iRowWalk <= iRowInsert ; iRowWalk++ )
    {
      if (iColumn)
      {
        if(typeof(t.children[iRowWalk].children[iColumn]) != "undefined")
          textRowCurrent = t.children[iRowWalk].children[iColumn].innerText;
        else
          textRowCurrent = "";
      }
      else
      {
        textRowCurrent = t.children[iRowWalk].innerText;
      }    //
    // We save our values so we can manipulate the numbers for
    // comparison
    //
      current = textRowCurrent;
      insert  = textRowInsert;    //  If the value is not a number, we sort normally, else we evaluate    
    //  the value to get a numeric representation
    //      if ( !isNaN(current) ||  !isNaN(insert)) 
      {
        current= eval(current);
        insert= eval(insert);
      }
      else
      {
        current=current.toLowerCase();
        insert= insert.toLowerCase();
      }      if ( (   (!fReverse && insert < current)
               || ( fReverse && insert > current) )
           && (iRowInsert != iRowWalk) )
      {
        eRowInsert = t.children[iRowInsert];
        eRowWalk = t.children[iRowWalk];
        t.insertBefore(eRowInsert, eRowWalk);
        iRowWalk = iRowInsert; // done
      }
    }
  }
}参考:有3个例子.各个不赖.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndude/html/dude07232001.asp客户端JS表格排序---摘自微软.

解决方案 »

  1.   

    http://www.9499.net/?go=tc
    阿赖的表格控件
      

  2.   

    http://msdn.microsoft.com/library/en-us/dndude/html/qualtogether.asp例子,给分各!
      

  3.   

    不错.不过程序有BUG  //  If the value is not a number, we sort normally, else we evaluate    
        //  the value to get a numeric representation
        //      if ( !isNaN(current) ||  !isNaN(insert)) 
    应为
         if ( !isNaN(current) &&  !isNaN(insert)) 
      

  4.   

    http://webfx.eae.net 这儿不是有一些吗?
      

  5.   

    http://webfx.eae.net/dhtml/sortabletable/largetabledemo.html