Sorting a table client side using one line of code

This little Java script allows you to sort a table client side using one line of code.

Here is an Example. Just click on the table headers.

In order to do this all you need to do is include the above JavaScript file. To enable the table all you have to do is assign it a unique ID and have the class="sortable". Like such::

<InvalidTag type="text/javascript" src="js/sorttable.js"></script>

<table id="t1" class="sortable">

<tr>
   <th>Name</th>
   <th>Salary</th>
   <th>Extension</th>
   <th>Start date</th>
</tr>
<tr>
   <td> Bloggs, Fred</td>
   <td>$12000.00</td>
   <td>1353</td>
   <td>18/08/2003</td>
</tr>
<tr>
   <td> Turvey, Kevin</td>
   <td>$191200.00</td>
   <td>2342</td>
   <td>02/05/1979</td>
</tr>
<tr>
   <td>Mbogo, Arnold</td>
   <td>$32010.12</td>
   <td>2755</td>
   <td>09/08/1998</td>
</tr>

<tr>
   <td> Shakespeare, Bill </td>
   <td>$122000.00</td>
   <td>3211</td>
   <td>12/11/1961</td>
</tr>

</table>

Ajax Rules

Comments

Calendar

NAVIGATION

Recent Entries

Recent Comments

RSS

Search

Subscribe

Tags