refactored table sorting click events