After loading the page just trigger a click on the header column you want to sort. Try with following javascript
code. I assume that there is only one table in the page. Perhaps you will need to be more specific using getElementsByTagName
or with getElementById
instead. The [1]
is the column number. You don't need to attach a click handler before that because that task is done by the code of sorttable.js
.
<script src="js/sorttable.js"></script>
<script>
window.onload = function() {
(document.getElementsByTagName( 'th' )[1]).click();
};
</script>