- fixed the table sorting functions