This is a great question. I don’t know how much scientific research has actually been done about this. Our experience and often my recommendation to folks (especially those who are not growing a ton of tall crops like corn) is to orient beds based on land first then on the sun. To me, it’s more important that you get the drainage or water retention. However, if possible or if working with perfectly flat land, then east west has always been our preference. No science there, just from our experience.
What Jesse said here about the lay of the property is most important. I've gone with North to South because I'm pretty far south (north texas) and running them N-S causes the least amount of shade being cast by crops/greenhouses/structures.
I always thought E W was preferred as long as tallest crops were planted in the northernmost rows or beds.
for me beds should be placed based on climate and crop. we prefer keyline patterning in our context. in low rainfall events all of the water infiltrates into the soil, where in high runoff evens the water is pushed towards the ridges and hydrates as much as possible before running into overflow access ( in our case planted with white clover to prevent erosion) this way you get no damage like overflowing beds in contour systems and the benefits of high infiltration in contour beds.