The total amount of sugar is less important than the glycemic load and the insulin response caused. Carrots are high in fibre.
"The glycemic index is a value assigned to foods based on how slowly or how quickly those foods cause increases in blood glucose levels" [1]
Coca Cola® (63) vs Carrots (39). Higher is worse.
[1] https://www.health.harvard.edu/diseases-and-conditions/glyce...