Dev Helpers
← Back

Sort query keys

Sort query keys using Node.js.

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