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.

ItemPriceDate
Teddy bear$160002/30/2005
Car$100,000.5001/25/2005
Notebook$4212/25/2006
Pen$ 303/16/2019

Instruction video