added sorting to gallery