tr = tr.sort(function(a,b) {
var cm, la, lb
la = a.cells[col] ; // get cell being sorted
lb = b.cells[col] ; // get cell being sorted
switch(typ) {
case 1:  // sort column contains integers
cm = (parseInt(la.innerHTML) > parseInt(lb.innerHTML)) ? 1 : -1 ;
break ;
case 2:  // sort column contains number in an attribute
cm = (parseFloat(la.getAttribute('data-foldersize')) > parseFloat(lb.getAttribute('data-foldersize'))) ? 1 : -1 ;
break ;
case 3: // sort column contains GMT date in an attribute
cm = (la.getAttribute('data-gmtdate') > lb.getAttribute('data-gmtdate')) ? 1 : -1 ;
break ;
default: // sort column contains a string, possibly inside an <a> tag
la = ((null !== la.firstElementChild) ? la.firstElementChild : la).innerHTML.toLowerCase() ;
lb = ((null !== lb.firstElementChild) ? lb.firstElementChild : lb).innerHTML.toLowerCase() ;
cm = la > lb ? 1 : -1 ;
}