# Ordering & Pagination with the Entity Service API

> Source: https://docs.strapi.io/cms/api/entity-service/order-pagination

Order and paginate Entity Service API query results using `sort`, `start`/`limit`, or `page`/`pageSize` parameters to control result ordering and retrieve specific data subsets.

:::caution
The Entity Service API is deprecated in Strapi v5. Please consider using the [Document Service API](/cms/api/document-service) instead.
:::

The [Entity Service API](/cms/api/entity-service) offers the ability to [order](#ordering) and [paginate](#pagination) results found with its [findMany()](/cms/api/entity-service/crud#findmany) method.

## Ordering

To order results returned by the Entity Service API, use the `sort` parameter. Results can be ordered based on a [single](#single) or on [multiple](#multiple) attribute(s) and can also use [relational ordering](#relational-ordering).

### Single

To order results by a single field, pass it to the `sort` parameter either:

- as a `string` to sort with the default ascending order, or
- as an `object` to define both the field name and the order (i.e. `'asc'` for ascending order or `'desc'` for descending order)

```js
strapi.entityService.findMany('api::article.article', {
  sort: 'id',
});

// single with direction
strapi.entityService.findMany('api::article.article', {
  sort: { id: 'desc' },
});
```

### Multiple

To order results by multiple fields, pass the fields as an array to the `sort` parameter either:

- as an array of strings to sort multiple fields using the default ascending order, or
- as an array of objects to define both the field name and the order (i.e. `'asc'` for ascending order or `'desc'` for descending order)

```js
strapi.entityService.findMany('api::article.article', {
  sort: ['publishDate', 'name'],
});

// multiple with direction
strapi.entityService.findMany('api::article.article', {
  sort: [{ title: 'asc' }, { publishedAt: 'desc' }],
});
```

### Relational ordering

Fields can also be sorted based on fields from relations:

```js
strapi.entityService.findMany('api::article.article', {
  sort: {
    author: {
      name: 'asc',
    },
  },
});
```

## Pagination

To paginate results returned by the Entity Service API, you can use the `start` and `limit` parameters:

```js
strapi.entityService.findMany('api::article.article', {
  start: 10,
  limit: 15,
});
```

You may instead use the `page` and `pageSize` parameters:

```js
strapi.entityService.findMany('api::article.article', {
  page: 1,
  pageSize: 15,
});
```
