Added sorting to galleries