Patch any holes and such in walls and trim, sand as necessary, dust, caulk. Paint ceiling first, then trim(except the baseboard), walls, baseboard, doors. If there is crown I may choose to paint that first, I like to move as fast as possible on the crown to maintain a wet edge so the paint lays down nicely.
Dry times are important to consider and may change the order of certain things, especially in smaller rooms where things move fast(er). For instance, larger holes in the walls require time to dry before sanding, so I may cut in the ceiling before sanding the walls. Because dust from sanding will fall on the baseboard, caulking the baseboard may wait until after sanding the walls. I don't want sanding dust falling on wet caulk, don't want to dig into wet(or skinned over) caulk when dusting the base, especially larger gaps or when new baseboard has been installed. When painting the walls I may cut-in at the base first, giving ample time for paint to dry in the inside corner at the top of the base so I don't run into wet wall paint when finally painting the base. Caulking inside corners can at times require added dry time consideration, higher quality caulks require longer dry times, you don't want to dig out the caulk with your brush. Paint over caulk often takes longer to dry than say the wall/ceiling inside corner. If I am painting the crown first, I may caulk the crown before patching the walls. There is a method to the madness applies. especially in smaller rooms where things move more quickly.
A typical repaint, first step may be a pole sander on walls or ceiling, or both, as necessary.
Of course on new or remodel work, all new plaster/drywall, raw wood, etc, will be primed first to stabilize the surface before caulking. That may require cut-in the new drywall/plaster, caulk trim, roll primer on walls(to allow trim caulk to dry), etc. etc.