Sleeping in the sun is a common trait in cats, as they seek out the toastiest location in the home, whether that is the window sill, rug or couch.
The reason why cats sleep in the sun is in order to conserve energy while they sleep, as their body temperature drops.