How to sort object array based on key in typescript [duplicate]
It's the same as plain old javascript. You can still use an arrow function to make it more concise.
x.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
Or using localeCompare.
x.sort((a, b) => a.name.localeCompare(b.name))