function sortTable(tname,col,typ) {
/*
Sort table using javascript array sort
based on https://stackoverflow.com/questions/14267781/sorting-html-table-with-javascript
tname is the ID of the table
col is the column number to sort on (0 to n)
typ is the type of data (see Switch statement below
*/
var sortattr = 'data-sort', i ;  // data attribute tag name
var tabl = document.getElementById(tname) ;  // get table object
var tb = tabl.tBodies[0] ; // get table tbody object
var thdr = tabl.tHead.rows[0].cells ;  // get cells in table header row
var sd = thdr[col].getAttribute(sortattr) == 'A' ? -1 : 1 ;  // get sort direction (A/D) (A if no prior sort)
var tr = Array.prototype.slice.call(tb.rows, 0) ; // get rows in array
for (i = 0; i < (thdr.length); i++) {
thdr[i].classList.remove('trasc','trdesc');  /* clear table header classes  */
thdr[i].setAttribute(sortattr, 'U');  // set all cols sort direction to unsorted
}