Does it make sense to work on the hardwood floor first, not last?
No. Modern "dustless" sanders are quite clean, and if you have to wipe some walls it is still likely less work than protecting the floor perfectly. And while you can always clean up dust, you can't touch up paint drips or floor scratches nearly as easily.

I made this mistake. I painted after doing floors in my kitchen renovation, because the floors were hired out but I did the painting myself later. There are some small drips of paint still visible on the floor. Not a huge deal, and I could have been more careful and avoided them, but if the order were reversed it would not have been a problem.

So bottom line, you can do either approach, but all other things being equal, it's preferable to paint before refinishing floors.