Generation

generate functionWed, 22 Mar 2023

I need a function that compares an array of objects and sorts them, these objects can have objects as attributes.

function sortArray(array, key) { array.sort((a, b) => (a[key] > b[key]) ? 1 : -1); }

TypeScript
Generate More

Questions about programming?Chat with your personal AI assistant