sorttable.js file in this project repository can be used by anyone to sort their html tables dynamically.
A complete working example of a html table file is also added now for learning and testing puposes here.
Screenshot of this example is given below.
** Instructions: **
- Download this repository by clicking on the Code Button above and choose "Download ZIP" option.
- Extract the ZIP file and then copy the sorttable.js file to your HTML Table file folder.
- Add the line:
<script src="sorttable.js"></script>
to your HTML Table file, in its head section. - Add class="sortable" to any table tag definition, that you have, to make it sortable.
- Click on any table headings to see it sort dynamically.
For Point 3. above, Alternately, you can use the following script/src tag value given below, in the head section of your html file, for an online reference to this javascript file:
<script src="https://cdn.jsdelivr.net/gh/linuxguist/sorttable@main/sorttable.js"></script>
If you need further help, then view and edit the .html file present in this download ZIP file, both on the Internet Browser and on good Code/Text Editors like Sublime Text OR Kate OR Geany OR Notepad++ OR Programmer's Notepad, for the syntax used therein. Search for keywords used there quickly.
This javascript code written originally by Stuart Langridge has been enhanced by me, in two ways:
- Replaced the Down/Up arrow icons with nice looking unicode counterparts.
- The sort ascending and descending order icons are shown appropriately.
Thanks to Stuart Langridge and many others for contributing the original code.
I thank the following forum article for inspiring me to develop this project idea: https://www.sololearn.com/Discuss/2497295/how-to-host-my-js-files-online-for-private-use-yourjavascript-com-is-not-working