Sort tables Bookmarklet

Sorting html tables with ID as a first column

Source (stackoverflow.com)


Download Bookmarklet:


View Bookmarklet Code:

Bookmarklet Source Code:

javascript%3A%28function%28%29%7Bvar%20table%2Crows%2Cswitching%2Ci%2Cx%2Cy%2CshouldSwitch%3Bswitching%3Dtrue%3Bwhile%28switching%29%7Bswitching%3Dfalse%3Brows%3Ddocument.getElementsByTagName%28%22TR%22%29%3Bfor%28i%3D1%3Bi%3C%28rows.length-1%29%3Bi++%29%7BshouldSwitch%3Dfalse%3Bx%3Drows%5Bi%5D.getElementsByTagName%28%22TD%22%29%5B0%5D%3By%3Drows%5Bi+1%5D.getElementsByTagName%28%22TD%22%29%5B0%5D%3Bif%28Number%28x.innerHTML%29%3ENumber%28y.innerHTML%29%29%7BshouldSwitch%3Dtrue%3Bbreak%3B%7D%3B%7D%3Bif%28shouldSwitch%29%7Brows%5Bi%5D.parentNode.insertBefore%28rows%5Bi+1%5D%2Crows%5Bi%5D%29%3Bswitching%3Dtrue%3B%7D%3B%7D%3B%7D%29%28%29%3B


Rate it:


Tags:

Comments

Comments so far. Add yours.