adding sorting to the tables and links to related tables