[API reference](https://evolu.dev/docs/api-reference) › [@evolu/sqlite-wasm](https://evolu.dev/docs/api-reference/sqlite-wasm) › [c-api](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api) › sqlite3\_create\_collation\_v2

```ts
function sqlite3_create_collation_v2(
  deps: SqliteWasmDep,
): (
  db: SqliteDbPtr,
  zName: CStringPtr,
  eTextRep: number,
  pArg: 0 | WasmPtr,
  xCompare: 0 | SqliteFunctionPtr,
  xDestroy: 0 | SqliteFunctionPtr,
) => SqliteResultCode;
```

Defined in: [packages/sqlite-wasm/src/CApi.ts:2639](https://github.com/evoluhq/evolu/blob/bc4578a260dd15d5bbf94b83765ca05984d194cb/packages/sqlite-wasm/src/CApi.ts#L2639)

Works like [sqlite3\_create\_collation](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api/functions/sqlite3_create_collation), and SQLite calls a non-NULL
xDestroy with pArg when the collation is replaced or the connection closes.
Unlike other SQLite functions, it does not call xDestroy when this call
fails, so the caller then disposes of pArg.

Wasm type `i(iiiiii)`. Signature `["sqlite3_create_collation_v2", "int",
"sqlite3*", "string", "int", "*", "funcptr:i(pipip)", "funcptr:v(p)"]` from
Evolu's supplement: SQLite binds it by hand to accept JavaScript functions as
callbacks.

See https://sqlite.org/c3ref/create_collation.html.