<!DOCTYPE html>
<script>
addEventListener('DOMContentLoaded', function () {
var tds = document.querySelectorAll('#TB td')
var texts = [].map.call(tds, function (e) {return e.textContent})
function observer(recs) {
recs.forEach(function (rec) {
tds[rec.name].textContent = texts[rec.name]
})
}
Object.observe(texts, observer);
texts.sort(function (a, b) {
Object.deliverChangeRecords(observer)
return (!a || !b) ? a < b : a > b
})
})
</script>
<table id='TB'><tr>
<td></td>
<td>ccc</td>
<td>aaa</td>
<td></td>
<td>ddd</td>
<td>bbb</td>
</tr></table>
PCFET0NUWVBFIGh0bWw+CjxzY3JpcHQ+CgphZGRFdmVudExpc3RlbmVyKCdET01Db250ZW50TG9hZGVkJywgZnVuY3Rpb24gKCkgewoKCXZhciB0ZHMgID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvckFsbCgnI1RCIHRkJykKCXZhciB0ZXh0cyA9IFtdLm1hcC5jYWxsKHRkcywgZnVuY3Rpb24gKGUpIHtyZXR1cm4gZS50ZXh0Q29udGVudH0pCgoJZnVuY3Rpb24gb2JzZXJ2ZXIocmVjcykgewoJCXJlY3MuZm9yRWFjaChmdW5jdGlvbiAocmVjKSB7CgkJCXRkc1tyZWMubmFtZV0udGV4dENvbnRlbnQgPSB0ZXh0c1tyZWMubmFtZV0KCQl9KQoJfQoKCU9iamVjdC5vYnNlcnZlKHRleHRzLCBvYnNlcnZlcik7CgoJdGV4dHMuc29ydChmdW5jdGlvbiAoYSwgYikgewoJCU9iamVjdC5kZWxpdmVyQ2hhbmdlUmVjb3JkcyhvYnNlcnZlcikKCQlyZXR1cm4gKCFhIHx8ICFiKSA/IGEgPCBiIDogYSA+IGIKCX0pCgp9KQoKPC9zY3JpcHQ+CgoKPHRhYmxlIGlkPSdUQic+PHRyPgo8dGQ+PC90ZD4gCjx0ZD5jY2M8L3RkPiAKPHRkPmFhYTwvdGQ+IAo8dGQ+PC90ZD4gCjx0ZD5kZGQ8L3RkPiAKPHRkPmJiYjwvdGQ+ICAKPC90cj48L3RhYmxlPg==