How are pages reallocated in a a data file after shrinkfile sql server
The shrink algorithm works exactly as you described it. A good description can be found in Paul Randal's blog: https://www.sqlskills.com/blogs/paul/why-you-should-not-shrink-your-data-files/


  Why does this happen? A data file shrink operation works on a single
  file at a time, and uses the GAM bitmaps (see Inside The Storage
  Engine: GAM, SGAM, PFS and other allocation maps) to find the highest
  page allocated in the file. It then moves it as far towards the front
  of the file as it can, and so on, and so on.


In your example, Page5 ends up in Empty1.