Added sort in subquery paginated query