The direction of growth of plants in general is dictated by gravity, not by the sun. (How would seeds underground otherwise know which way to grow to get the leaves above ground ASAP?)
IIRC, there’re growth hormones that are both less and greater density than plant cell contents in general.
So, a root that is growing sideways out of a seed (yes, the structures growing out of a seed are initially in a specific direction) will accumulate the less dense hormone on the side of its cells that is facing up. Those cells will grow a little lopsided, slowly pusing down the direction of the growth at the root tip, which is directed by a different process. (Imagine an opposite effect in the stem cells using the heavier hormone.)
One experiment I did in HS biology was to fill a paper towel with soil and stuff it into a Mason jar. Then I pushed beans down the sides of the jar (between the glass and the paper towel). The beans were in various orientations. When they sprouted, the roots came out in one specific direction relative to the beans orientation and the stem in the opposite direction. Then, after both had cleared the bean by about 1/2 inch, they started growing up (stems) or down (roots) as usual.
IIRC, experiments on the Space Shuttles have show that seeds lose this direction sense in zero gravity (aka free fall). They grow any which way, and would probably be influenced if the ship had a extended acceleration in a particular direction, simulating gravity.