When it comes to orientation of a heat sink, you need to chose whichever method gives you the best airflow over the heat sink.
Heat-sinks work, primarily1, by transferring heat through a large surface area to the ambient air in contact with that surface. If the air can not move, the air quickly heats up and heat transfer from the metal drops off.
As such, you want the air to move, or be driven, through and away from the heat-sink as it heats up. Hopefully to be replaced with fresh cooler air.
Hot air also rises.
As such, if it is not a forced air system, you need to align the fins of the heat-sink so air can rise up between the fins as easily as possible2, so a flow can be established.
Of your images, perhaps you can see that in the first one, hot air will collect near the top, so efficiency is reduced
The second image is actually not that much better since air coming out of the heatsink is obstructing air going in.
Your ultimate is the third orientation you have not shown...
If this is a forced air system, again, you need to arrange the fins so the air is blown between them in the same manner. Orientation then becomes "orientation with respect to the primary air-flow".
Also. I have to mention, you need to exhaust that hot air somewhere. Just circulating it around inside a box only delays over-heating.
You should also read my other answer here.
1The other transfer method is of course radiant heat.
2Some turbulence is actually a good thing. Air that passes through that does not make contact with the surface performs little cooling. As such :