Open this example in the interactive library
Source code
import { URLSearchParams } from "node:url";
console.log(
(() => {
const p = new URLSearchParams("z=1&a=3");
p.sort();
return p.toString();
})(),
);
Sample output
a=3&z=1

Open this example in the interactive library
import { URLSearchParams } from "node:url";
console.log(
(() => {
const p = new URLSearchParams("z=1&a=3");
p.sort();
return p.toString();
})(),
);
a=3&z=1