Added sorting of tables