sortKeys es-toolkit
Creates a new object with the keys sorted.
Usage
sortKeys(object, compareKeys?)
Use sortKeys when you want to create a new object with its keys in a deterministic order. Keys are sorted alphabetically by default, which is useful for serialization, comparison, or display purposes.
You can also provide a custom compare function for different sorting behavior.
Values are preserved as-is, including nested objects and arrays.
Parameters
objectTrequired
The object to sort keys from.
compareKeys(a: string, b: string) => numberoptional
A custom compare function for sorting keys. Defaults to alphabetical order.
Returns
A new object with the keys sorted.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.