I am using a Javascript behavior for sorting data in a table. An example can be found here: http://msdn.microsoft.com/library/de...de07232001.asp.

The sorting alogorithm used is InsertionSort. When I have over 200 rows in a table it gets extremely slow. So I am thinking about implementing Quicksort.

Can anyone give me a hand how to convert this function into Quicksort algorithm?

Code:
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
            }
        }
    }
}
Thanks in advance.