Probably will work, because rails use Arel to build query (lazy create it) but better is to call next part of query in proper order. 
- first search
- then sort
- limit page

right now you first limit to page for example 2, and then order by ... and then search