How to preserve window views through undo of external command?

Open a new buffer with this text:

This
is
a
test

Then split the window so there are now two windows loaded with the same buffer. Observe that if you run :%sort and then u to undo, both windows revert to their previous states. However, if you run :%!sort and then u to undo, the other window will scroll so that only the last line is visible. What causes this behavior, is it intentional or a bug, and how can I work around it?