Skip to content

Commit b03718e

Browse files
committed
refactor: streamline sorting functions and improve code readability
1 parent 1daffb4 commit b03718e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

governance/xc_admin/packages/xc_admin_common/src/programs/core/core_functions.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,10 @@ function checkSizeOfProductInstruction(
6868
/**
6969
* Sort object by keys
7070
*/
71-
function sortObjectByKeys<T extends Record<string, unknown>>(obj: T): T {
72-
const sortedObj = {} as T;
73-
const keys = Object.keys(obj).sort();
74-
for (const key of keys) {
75-
sortedObj[key as keyof T] = obj[key] as T[keyof T];
76-
}
77-
return sortedObj;
78-
}
71+
const sortObjectByKeys = <T extends Record<string, unknown>>(obj: T): T =>
72+
Object.fromEntries(
73+
Object.entries(obj).sort(([a], [b]) => a.localeCompare(b)),
74+
) as T;
7975

8076
/**
8177
* Sort configuration data for consistent output

0 commit comments

Comments
 (0)