Home > @rushstack/node-core-library > Sort > sortKeys
Sort.sortKeys() method
Sort the keys deeply given an object or an array.
Doesn't handle cyclic reference.
Signature:
static sortKeys<T extends Partial<Record<string, unknown>> | unknown[]>(object: T): T;
Parameters
Parameter | Type | Description |
|---|---|---|
object | T | The object to be sorted |
Returns:
T
Example
console.log(Sort.sortKeys({ c: 3, b: 2, a: 1 })); // { a: 1, b: 2, c: 3}