sort before paginate