title: Sort array of objects by two properties JS
body: <p>I have a long array of objects like this. How do I sort it by continents first and alphabetically by countries for each continent?</p>
  <p>Sorry, if my wording is wrong. My first question on SO :)</p>
  <pre><code>[
      {country: 'Afghanistan', continent: 'Asia'},
      {country: 'Åland Islands', continent: 'Europe'},
      {country: 'Albania', continent: 'Europe'},
      {country: 'Algeria', continent: 'Africa'},
      {country: 'American Samoa', continent: 'Oceania'},
      {country: 'Andorra', continent: 'Europe'},
      {country: 'Angola', continent: 'Africa'},
      {country: 'Anguilla', continent: 'North America'},
      {country: 'Antarctica', continent: 'Antarctica'},
  ]
  </code></pre>
  <p>I have tried this code and only managed to sort it by countries.</p>
  <pre><code>myArray.sort((a, b) =&gt; {
      const countryA = a.country;
      const countryB = b.country;
      const continentA = a.continent;
      const continentB = b.continent;
      return countryA.localeCompare(countryB) || continentA - continentB;
    })
  </code></pre>