# 按ID排序不再能够按时间顺序排序

> Source: https://strapi.nodejs.cn/cms/migration/v4-to-v5/breaking-changes/sort-by-id

🌐 Sorting by `id` is no longer possible to sort by chronological order in Strapi 5

由于基于 UUID 的文档，Strapi 5 中按 `id` 排序不再按时间顺序工作；请改用 Document Service API 的 `createdAt`。

🌐 Sorting by `id` no longer works chronologically in Strapi 5 due to uuid-based documents; use `createdAt` with the Document Service API instead.

在 Strapi 5 中，由于[文档](/cms/api/document)使用 UUID，因此不能再通过 `id` 进行按时间顺序排序。

🌐 In Strapi 5, sorting by `id` to sort by chronological order is no longer possible since [documents](/cms/api/document) use an uuid.

此页面是[重大更改数据库](/cms/migration/v4-to-v5/breaking-changes)的一部分，提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

🌐 This page is part of the [breaking changes database](/cms/migration/v4-to-v5/breaking-changes) and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

- Is this breaking change affecting plugins? Yes
- Is this breaking change automatically handled by a codemod? Yes
  - Codemod: [entity-service-document-service](https://github.com/strapi/strapi/blob/develop/packages/utils/upgrade/resources/codemods/5.0.0/entity-service-document-service.code.ts)

## 重大变更描述 {#breaking-change-description}

🌐 Breaking change description

**在 Strapi v4 中**

在 Strapi v4 中，使用实体服务 API，你可以执行以下操作按时间顺序对条目进行排序：

🌐 In Strapi v4, using the Entity Service API, you could do the following to sort entries by chronological order:

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

**在 Strapi 5 中**

在 Strapi 5 中，使用 [文档服务 API](/cms/api/document-service) 按时间顺序对文档进行排序，使用 `createdAt` 字段：

🌐 In Strapi 5, use the [Document Service API](/cms/api/document-service) to sort documents by chronological order, use the `createdAt` field:

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

## 迁移 {#migration}

🌐 Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

🌐 This section regroups useful notes and procedures about the introduced breaking change.

### 手动操作 {#manual-procedure}

🌐 Manual procedure

不需要手动程序，因为这将由代码修改处理。

🌐 No manual procedure should be required as this will be handled by a codemod.
