JS Built-ins
URLSearchParamsintermediate

URLSearchParams#sort() β€” sort by key name

πŸ“– Usage Example
const p = new URLSearchParams('b=2&a=1')
p.sort()
p.toString()  // β†’ 'a=1&b=2'

sort() sorts parameters by key in Unicode order, useful for canonical URLs.

URLSearchParams#sort()

params.sort() sorts all key-value pairs in-place by their key names (Unicode order).

Challenge: Sort params and verify the key order.

πŸ’‘ Hints (1)
  • β€’ sort() modifies the params object in-place and returns undefined