When clicking on a column to sort, the new sorting column isn't stored in $th.
Example :
tablesort.sort($("th.t1"))
tablesort.$th is now th.t1 element
Then, clicking on th.t2 column to sort
tablesort.$th is still th.t1 element. No update.
Proposed fix :
Store new sorted column element in $th