I would like to sort an array of objects by a certain string value. For example, I have the below array of objects:
const stores = [
{id: 1, name: 'Store1', country: 'USA'},
{id: 2, name: 'Store2', country: 'Canada'},
{id: 3, name: 'Store3', country: 'USA'},
{id: 4, name: 'Store4', country: 'Canada'}
];
I would like to sort that array so all the objects with a country value of 'Canada' is first. I know you can sort by number, but I am not sure how to sort by a string value. How would I go about doing this? Thank you in advance!