Adding new function for table sorting