Well, either way is possible, depending on the condition of your floor and walls. The experts advise that in any way, heavy prep work on your ceiling and walls (wallpaper removal, replastering) should be done before refinishing your floor. And if the latter needs aggressive sanding, first, paint the walls beforehand to avoid dust ending up on the walls. You can easily place a drop sheet to avoid paint splashes going on your restored flooring. Still, if modern dust-free technology is used for sanding lightly the floor surface, then you can paint the walls and ceiling before calling in the floor sanding experts.