UNPKG

1.03 kBTypeScriptView Raw
1/** A typical comparator for sorting object keys */
2type KeyComparator = (a: string, b: string) => number;
3/** An indexable object */
4type IndexedObject = {
5 [key: string]: any;
6};
7/**
8 * Returns a copy of the passed array, with all nested objects within it sorted deeply by their keys, without mangling any nested arrays.
9 * @param subject The unsorted array.
10 * @param comparator An optional comparator for sorting keys of objects.
11 * @returns The new sorted array.
12 */
13export declare function sortArray<T extends any[]>(subject: T, comparator?: KeyComparator): T;
14/**
15 * Returns a copy of the passed object, with all nested objects within it sorted deeply by their keys, without mangling any nested arrays inside of it.
16 * @param subject The unsorted object.
17 * @param comparator An optional comparator for sorting keys of objects.
18 * @returns The new sorted object.
19 */
20export default function sortObject<T extends IndexedObject>(subject: T, comparator?: KeyComparator): T;
21export {};
22//# sourceMappingURL=index.d.ts.map
\No newline at end of file