fork(1) download
  1. <!DOCTYPE html>
  2. <script>
  3.  
  4. addEventListener('DOMContentLoaded', function () {
  5.  
  6. var tds = document.querySelectorAll('#TB td')
  7. var texts = [].map.call(tds, function (e) {return e.textContent})
  8.  
  9. function observer(recs) {
  10. recs.forEach(function (rec) {
  11. tds[rec.name].textContent = texts[rec.name]
  12. })
  13. }
  14.  
  15. Object.observe(texts, observer);
  16.  
  17. texts.sort(function (a, b) {
  18. Object.deliverChangeRecords(observer)
  19. return (!a || !b) ? a < b : a > b
  20. })
  21.  
  22. })
  23.  
  24. </script>
  25.  
  26.  
  27. <table id='TB'><tr>
  28. <td></td>
  29. <td>ccc</td>
  30. <td>aaa</td>
  31. <td></td>
  32. <td>ddd</td>
  33. <td>bbb</td>
  34. </tr></table>
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty