URL
URLSearchParams.sort()
Sorts query names in place, preserving relative order among equal names. Do not normalize signed query strings without knowing the signature scheme. Tested on Node.js 22.16.0. Example output (one line per entry): ["a=2&a=1&z=1"].
Formal Syntax & Structure
nodejs syntaxnodejs
params.sort()Return Value
undefined
Mutates collection.
Working Example
Example Snippetnodejs
const p = new URLSearchParams('z=1&a=2&a=1');p.sort();console.log(p.toString());