Web APIs

URLSearchParams.sort()

Try the free JavaScript compiler

Sort pairs in place by name using UTF-16 code units; pairs with equal names retain their order. Example console output: a=2&a=1&z=3.

Formal Syntax & Structure

javascript syntaxjavascript
params.sort()

Return Value

undefined

No result value.

Working Example

Example Snippetjavascript
const p=new URLSearchParams("z=3&a=2&a=1"); p.sort(); console.log(p.toString());
JavaScript Reference