added sorting to tables