Returns an array of objects with nested sorting based on a set of specific shared keys.
function sortByKeyValues\<T extends object, U extends keyof T>(
objs: T[],
...keys: U[]
order?: ("asc" | "desc")[]
): T[]
// Example:
const obj1 = { a: 1, b: 6, c: 3 }
const obj2 = { a: 3, b: 2, c: 4 }
const obj3 = { a: 3, b: 2, c: 3 }
const obj4 = { a: 2, b: 4, c: 3 }
const obj5 = { a: 2, b: 5, c: 3 }
sortByKeyValues([obj1, obj2, obj3, obj4, obj5], "a", "b", "c")
//=>
[
{ a: 1, b: 6, c: 3 },
{ a: 2, b: 4, c: 3 },
{ a: 2, b: 5, c: 3 },
{ a: 3, b: 2, c: 3 },
{ a: 3, b: 2, c: 4 }
]