Sandoval shines as Giants hang on for win