テーブルの行をランダムに並び替える

function randomRows(tableId) {

 var i = 0
  var o;
  var table = document.getElementById(tableId)
 var tbody = table.getElementsByTagName('tbody')[0];
  var r;

 while (o = tbody.childNodes[i]) {
    if (3 == o.nodeType) {
      tbody.removeChild(o);
    } else {
      i++;
    }
  }

 while (--i) {
    r = Math.floor(1 + Math.random() * i);
    tbody.appendChild(tbody.childNodes[r]);
  }
  return true;
}