Page search uses viewState.sort

Originally page search was not prepared for the sort viewState, now it is.
For this, the applySort() was refactored to use the rootScope instead of the scope and produces both the predicate for the viewer and for the page search

Fixes #1148