Added sorting to tables