It usually is personal preference what order you paint in. It is recommended that you paint trim first, then cut ins, ceilings, and lastly walls.

Trim > Cut in’s > Ceilings > Walls