The Torah says: ‘Vayehi erev vayehi boker” (mentioning night before day). The Talmud also starts out by discussing the dinim of krias Shema at night. Why, then, does the Shulchan Aruch begin with the halachos that apply in the MORNING? Why doesn’t it follow the same pattern as the Chumash and the Talmud?
I heard an interesting answer to this question. The Shulchan Aruch made his order according to what is practical for the way that we live. On a practical level we start our day from the morning, even though in reality it starts from the night time- the way the mishnayos has the order.
Similar to this, the Rambam’s order his historical. Therefore he put Hilchos Megillah before Hilchos Chanukah, whereas in the Shulchn Aruch practically in the year Chanukah comes before Purim. It is interesting that in Hilchos shabbos the Shulchan Aruch discusses the halachos needed for the night time before those of the day. Again when we approach shabbos, practically it starts for us from the night time, so he wrote it first.