Tip: you can modify some code before running
<script language="vbscript">Sub doSort () set ob = window. event. srcElement if ob. tagName <> "TD" then exit sub sortDir = "" & ob. getAttribute ("sortDir") if sortDir = "" then sortDir = 1' first point in ascending order else sortDir =-1 * clng (sortDir) end if idx = ob. cellIndex do while true if ob. tagName = "TABLE" then exit do set ob = ob. parentElement loop cnt = ob. rows. length fromIdx = 0 for I = fromIdx to cnt-1 set trOb1 = ob. rows (I) cTxt = trOb1.cells (idx ). innerText sort =-1 for j = I + 1 to cnt-1 set trOb2 = ob. rows (j) cTxt2 = trOb2.cells (idx ). innerText if sortDir> 0 then if cTxt> cTxt2 then sort = j cTxt = cTxt2 end if else if cTxt<cTxt2 then sort=j cTxt=cTxt2 end if end if next if sort>0 then ob. rows (I ). swapNode ob. rows (sort) next set tdOb = ob. rows (fromIdx ). cells (idx) tdOb. setAttribute "sortDir", sortDir end sub</script><table border=1 onclick="doSort"> <tr><td>3 (1)</td><td>A</td><td>In</td><td>2007-1-2</td><td>1a</td><td> </td></tr> <tr><td>6 (2)</td><td>X</td><td>Dry</td><td>2006-5-1</td><td>Ab2</td><td>Y5t</td></tr> <tr><td>8 (3)</td><td>F</td><td>Ha</td><td>2007-3-5</td><td>3 hgda</td><td>566</td></tr> <tr><td>7 (4)</td><td>3</td><td>Me</td><td>2005-10-5</td><td>F5465</td><td>32</td></tr> <tr><td>2 (5)</td><td>B</td><td>Ah</td><td>2005-2-5</td><td>6 dgdf</td><td>77</td></tr> <tr><td>6 (6)</td><td>N</td><td>Yes</td><td></td><td>2gda</td><td>2004-5-1</td></tr> <tr><td>2 (7)</td><td>U</td><td>?</td><td>2004-2-10</td><td>1rds</td><td>Haha</td></tr></table>China WEB first stop
Tip: you can modify some code before running