> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supernote.com/llms.txt
> Use this file to discover all available pages before exploring further.

# sortLayers

> 对图层信息排序（最前面的图层在最顶端）。

<Note>
  只有笔记文件才有图层数据，其他文件没有图层数据。
</Note>

```ts wrap theme={null}
static sortLayers(notePath: string, page: number, layerIds: number[]): Promise<APIResponse<boolean>>;
```

**参数**

| 参数         | 类型         | 说明                          |
| ---------- | ---------- | --------------------------- |
| `notePath` | `string`   | 笔记文件路径                      |
| `page`     | `number`   | 页面索引（从 0 开始）                |
| `layerIds` | `number[]` | 需要排序的图层 ID （0-3）列表（顺序即层级顺序） |

**返回**

* [`APIResponse<boolean>`](/zh/api-reference/supernote-plugin/types/api-response)：
  `result === true` 表示排序成功

## 示例

```ts wrap theme={null}
import { PluginFileAPI } from 'sn-plugin-lib';

/**
 * 排序图层的示例（传入期望的层级顺序）。
 */
export async function exampleSortLayers() {
  const notePath = '/storage/emulated/0/Note/demo.note';
  const page = 1;
  const res = await PluginFileAPI.sortLayers(notePath, page, [2, 1, 0]);
  if (!res.success) {
    throw new Error(res.error?.message ?? 'sortLayers 调用失败');
  }
  return res.result;
}
```
