Peter Sagan ended a nine-month wait for a stage win as he sprinted to victory on Stage 3 of the Tour de Suisse.