Add sorting to gallery