If you're painting the entire room, paint the ceiling first, then paint the walls. Paint the trim last so paint doesn't drip or splatter on them while you're painting the walls.