Think about being outdoors on a cold morning with a clear sky. Whilst you're standing in the sunshine you can feel the radiation heat from it. If you go into the shade you immediately feel colder even though the air temperature is the same. Being in space would be like that; in fact spacemen wear special suits because the radiation from the sun is not filtered out by the atmosphere, so they would be toasted even though there was no heat outside. On earth the sun heats the ground and the ground heats the air, hence the higher you go the colder it is because the air up there is further away from the ground.