function buildForumSortedTable(table,cache,sortedByThread,original){

			//remove all the children, then insert all the sorted children for each parent row
			$(table.tBodies[0].rows).not($("tr.hierItemBlock")).remove();

			//Treating each parent row, adding children and grandchildren
			$(table.tBodies[0].rows).each(function(i){
				if(this.descendantCount == 0){
					return true;
				}
				else{
				
					if (!sortedByThread){
						for (var m = this.descendantCount -1; m > 0 || m == 0;  m--){
							//get child row number in the sorted cache
							var childRow = this.descendantRow[m];
							//append child
							$(cache.row[childRow]).insertAfter(this);
						}
					}
					else{
						//Get children sorted, keep logic of grandchildren and deeper descendents.
						for (var m = this.descendantCount -1; m > 0 || m == 0;  m--){
							//get children row numbers in the sorted cache
							var childRow = this.descendantRow[m];
							var leftpadding;
							var paddingValue;
							//make it working cross browsers and versions hopefully, fixed IE7 & 8
							leftpadding = $(cache.row[childRow][0].children[1]).css("padding-left");
							if(leftpadding.indexOf("px")>=0){
								var pixels = leftpadding.replace("px","");
								paddingValue = $(parseInt(pixels)).toEm();
							}
							else{
								   paddingValue = leftpadding;	
							}
							if(paddingValue == "1em"){
								// Insert child
								var insertedRow = $(cache.row[childRow]).insertAfter(this);
								// Find its grandchildren and insert them in the original order 
								var count = cache.row[childRow][0].grandChildrenCount;
								if(count != 0 ){
									var rowIndexArray = cache.row[childRow][0].grandChildrenRows;
									for (var n = 0; n < count; n++){
										insertedRow = $(original.row[rowIndexArray[n]]).insertAfter(insertedRow);
									}
								}
								
							}
						}//end of for	
					}
				}
			});
		}// end of buildForumSortedTable
/* 
		 * Build final sorted table for forum topic threads maintaining 
		 * parent - children - grandchildren relationship as needed
		**/
Build final sorted table for forum topic threads maintaining
parent - children - grandchildren relationship as needed
Build final sorted table for forum topic threads maintaining parent - children - grandchildren relationship as needed
function buildForumSortedTable(table,cache,sortedByThread,original){
			$(table.tBodies[0].rows).not($("tr.hierItemBlock")).remove();
			$(table.tBodies[0].rows).each(function(i){
				if(this.descendantCount == 0){
					return true;
				}
				else{
					if (!sortedByThread){
						for (var m = this.descendantCount -1; m > 0 || m == 0;  m--){
							var childRow = this.descendantRow[m];
							$(cache.row[childRow]).insertAfter(this);
						}
					}
					else{
						for (var m = this.descendantCount -1; m > 0 || m == 0;  m--){
							var childRow = this.descendantRow[m];
							var leftpadding;
							var paddingValue;
							leftpadding = $(cache.row[childRow][0].children[1]).css("padding-left");
							if(leftpadding.indexOf("px")>=0){
								var pixels = leftpadding.replace("px","");
								paddingValue = $(parseInt(pixels)).toEm();
							}
							else{
								   paddingValue = leftpadding;	
							}
							if(paddingValue == "1em"){
								var insertedRow = $(cache.row[childRow]).insertAfter(this);
								var count = cache.row[childRow][0].grandChildrenCount;
								if(count != 0 ){
									var rowIndexArray = cache.row[childRow][0].grandChildrenRows;
									for (var n = 0; n < count; n++){
										insertedRow = $(original.row[rowIndexArray[n]]).insertAfter(insertedRow);
									}
								}
							}
						}
					}
				}
			});
		}
function buildForumSortedTable ( table , cache , sortedByThread , original ) { $ ( table . tBodies [ 0 ] . rows ) . not ( $ ( "tr.hierItemBlock" ) ) . remove ( ) ; $ ( table . tBodies [ 0 ] . rows ) . each ( function ( i ) { if ( this . descendantCount == 0 ) { return true ; } else { if ( ! sortedByThread ) { for ( var m = this . descendantCount - 1 ; m > 0 || m == 0 ; m -- ) { var childRow = this . descendantRow [ m ] ; $ ( cache . row [ childRow ] ) . insertAfter ( this ) ; } } else { for ( var m = this . descendantCount - 1 ; m > 0 || m == 0 ; m -- ) { var childRow = this . descendantRow [ m ] ; var leftpadding ; var paddingValue ; leftpadding = $ ( cache . row [ childRow ] [ 0 ] . children [ 1 ] ) . css ( "padding-left" ) ; if ( leftpadding . indexOf ( "px" ) >= 0 ) { var pixels = leftpadding . replace ( "px" , "" ) ; paddingValue = $ ( parseInt ( pixels ) ) . toEm ( ) ; } else { paddingValue = leftpadding ; } if ( paddingValue == "1em" ) { var insertedRow = $ ( cache . row [ childRow ] ) . insertAfter ( this ) ; var count = cache . row [ childRow ] [ 0 ] . grandChildrenCount ; if ( count != 0 ) { var rowIndexArray = cache . row [ childRow ] [ 0 ] . grandChildrenRows ; for ( var n = 0 ; n < count ; n ++ ) { insertedRow = $ ( original . row [ rowIndexArray [ n ] ] ) . insertAfter ( insertedRow ) ; } } } } } } } ) ; }
Build final sorted table for forum topic threads maintaining
 parent - children - grandchildren relationship as needed
Build final sorted table for forum topic threads maintaining parent - children - grandchildren relationship as needed
//remove all the children, then insert all the sorted children for each parent row //Treating each parent row, adding children and grandchildren //get child row number in the sorted cache //append child //Get children sorted, keep logic of grandchildren and deeper descendents. //get children row numbers in the sorted cache //make it working cross browsers and versions hopefully, fixed IE7 & 8 // Insert child // Find its grandchildren and insert them in the original order  //end of for	 // end of buildForumSortedTable