> ## 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

> Sort layers (the first layer is on top).

<Note>
  Only NOTE files have layer data; other file types do not.
</Note>

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

**Parameters**

| Parameter  | Type       | Description                  |
| ---------- | ---------- | ---------------------------- |
| `NOTEPath` | `string`   | NOTE file path               |
| `page`     | `number`   | Page index (starts from `0`) |
| `layerIds` | `number[]` | Layer ID order (`0..3`)      |

**Returns**

* [`APIResponse<boolean>`](/en/api-reference/supernote-plugin/types/api-response):
  `result === true` indicates sorting succeeded

## Example

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

/**
 * Example: sort layers (pass the desired layer order).
 */
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 call failed');
 }
 return res.result;
}
```
