code refactoring tablesort.js