sortObjectByKey() — astro Function Reference
Architecture documentation for the sortObjectByKey() function in utils.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 1df9fd6d_c170_b96d_0505_6274bb0b9dd7["sortObjectByKey()"] 77c4177d_ca70_d1e3_9542_4dbf91aa1dfd["utils.ts"] 1df9fd6d_c170_b96d_0505_6274bb0b9dd7 -->|defined in| 77c4177d_ca70_d1e3_9542_4dbf91aa1dfd style 1df9fd6d_c170_b96d_0505_6274bb0b9dd7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/assets/fonts/utils.ts lines 72–86
export function sortObjectByKey<T extends Record<string, any>>(unordered: T): T {
const ordered = Object.keys(unordered)
.sort()
.reduce((obj, key) => {
const value = unordered[key];
// @ts-expect-error Type 'T' is generic and can only be indexed for reading. That's fine here
obj[key] = Array.isArray(value)
? value.map((v) => (typeof v === 'object' && v !== null ? sortObjectByKey(v) : v))
: typeof value === 'object' && value !== null
? sortObjectByKey(value)
: value;
return obj;
}, {} as T);
return ordered;
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does sortObjectByKey() do?
sortObjectByKey() is a function in the astro codebase, defined in packages/astro/src/assets/fonts/utils.ts.
Where is sortObjectByKey() defined?
sortObjectByKey() is defined in packages/astro/src/assets/fonts/utils.ts at line 72.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free