rem:  var allimgs = document.getElementsByTagName("img"); for (var ci=0;ci<allimgs.length;ci++) { if (allimgs[ci].className == 'sortarrow') { if (getParent(allimgs[ci],"table") == getParent(lnk,"table")) { allimgs[ci].setAttribute('src',NO_ARROW); allimgs[ci].setAttribute('alt',"&#x2195;"); } } } 
add: if (span.getAttribute("sortdir") == 'down') { ARROW = '<img src="'+ image_path + image_down + '" alt="&darr;"/>'; newRows.reverse(); span.setAttribute('sortdir','up'); } else { ARROW = '<img src="'+ image_path + image_up + '" alt="&uarr;"/>'; span.setAttribute('sortdir','down'); }    for (i=0; i<newRows.length; i++) { if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) { table.tBodies[0].appendChild(newRows[i]); } }  for (i=0; i<newRows.length; i++) { if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) table.tBodies[0].appendChild(newRows[i]); } 
context: function ts_resortTable(lnk) {    // get the arrow image    var img;    for (var ci=0;ci<lnk.childNodes.length;ci++) {        if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'img') img = lnk.childNodes[ci];    }    var reverse = (img.getAttribute("sortdir") == 'down');    var td = lnk.parentNode;    var column = td.cellIndex;    var table = getParent(td,'TABLE');    // Work out a type for the column    if (table.rows.length <= 1) return;    var itm = ts_getInnerText(table.rows[1].cells[column]);    sortfn = ts_sort_caseinsensitive;    // Note: The trailing \n$ is needed because that's how MediaWiki spits out its table syntax.    if (itm.match(/^\s*\d{2}[\/-]\d{2}[\/-]\d{4}\s*$/)) sortfn = ts_sort_date;    if (itm.match(/^\s*\d{2}[\/-]\d{2}[\/-]\d{2}\s*$/)) sortfn = ts_sort_date;    if (itm.match(/^\s*[?$]/)) sortfn = ts_sort_currency;    if (itm.match(/^\s*[\d\.]+\s*$/)) sortfn = ts_sort_numeric;    var firstRow = new Array();    var newRows = new Array();    for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }    for (j=1;j<table.rows.length;j++) {	var obj = new Object();	obj.row = table.rows[j];	obj.grp = ((' '+obj.row.className+' ').indexOf(' sortbottom ') == -1 ? 0 : reverse ? -1 : 1);	obj.txt = ts_getInnerText(obj.row.cells[column]);	obj.idx = (reverse ? -j : j);	newRows[j-1] = obj;    }    newRows.sort(sortfn);    if (reverse) {	ARROW = UP_ARROW;        newRows.reverse();        img.setAttribute('sortdir','up');    } else {	ARROW = DOWN_ARROW;        img.setAttribute('sortdir','down');    }    // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones    for (i=0;i<newRows.length;i++) { table.tBodies[0].appendChild(newRows[i].row); }    // Delete any other arrows there may be showing    var allimgs = document.getElementsByTagName("img");    for (var ci=0;ci<allimgs.length;ci++) {        if (allimgs[ci].className == 'sortarrow') {            if (getParent(allimgs[ci],"table") == getParent(lnk,"table")) { // in the same table as us?                allimgs[ci].setAttribute('src',NO_ARROW);                allimgs[ci].setAttribute('alt',"&#x2195;");            }        }    }    img.setAttribute('src',ARROW);    img.setAttribute('alt',img.getAttribute("sortdir") == 'down' ? '&darr;' : '&uarr;');}
meta: 7328	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/7328/aecab3c29373db6e82c71b74856d5e1e7473ce96/sorttable.js/buggy/skins/common/sorttable.js