How to enable table sorting?
Our HTML Tables Generator allows to add a simple, one-column sortingfunctionality to the generated table. This allows user to click on a column header to sort the table’s rows. By clicking repeatedly it is possible to change sorting direction or return to the original ordering of the rows.
If the sorting is enabled, the (generated) table’s source contains additionalsource code of the sorting script:
...
</table>
<script charset="utf-8">var TGSort=window.TGSort...</script>
The sorting script is very simple and supports only the most-basic functionality allowing to sort:
- text
- numbers
- currency (partially)
- dates (partially)
Example table
Please, click on one of the headers (Item
, Price
, Date
) of the table below to check the sorting functionality. Clicking few times cycles between sorting directions and the original ordering.
Item | Price | Date |
---|---|---|
Teddy bear | $1600 | 02/30/2005 |
Car | $100,000.50 | 01/25/2005 |
Notebook | $42 | 12/25/2006 |
Pen | $ 3 | 03/16/2019 |