paginate and sort search results