Is there a way to alphabetically sort an array of objects in Typescript based on a specific field? The array I have currently looks like this - https://i.stack.imgur.com/fQ3PA.png I'm interested in sorting it alphabetically by the 'channel' field.
I attempted the following approach that I found online. Although it didn't throw any errors, it also didn't give me the results I was expecting.
this.currentPickSelection = this.currentPickSelection.sort((a, b) => {
if (a.channel > b.channel) {
return 1;
}
if (a.channel < b.channel) {
return -1;
}
return 0;