The Sun was created before the Moon. According to scientific understanding, the Sun formed approximately 4.6 billion years ago as a result of the collapse of a giant molecular cloud of gas and dust. This event marked the beginning of the solar system's formation.
The Moon, on the other hand, is believed to have formed shortly after the formation of the Sun. The prevailing theory, known as the Giant Impact Hypothesis, suggests that a Mars-sized object collided with the young Earth early in its history, ejecting a large amount of debris into space. Over time, this debris coalesced and eventually formed the Moon.
So, while both the Sun and the Moon are ancient celestial bodies, the Sun came into existence first, followed by the formation of the Moon during the early stages of the solar system's evolution.