title: Sort Js array of object by two values
body: <p>I am working on one small application <br>
  in that i want to sort the array of objets by two values <br>
  one is time stamp and one in string</p>
  <p>I tried this below snippet but its not satisfying the below condition</p>
  <p>I want this object mentioned in snippet should sorted based on the object should contain sport as <code>cricket</code> first and empty value as second and both are sorted by date ascending order</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var content =  [
          {
              "first_name": "musk",
              "sport": "cricket",
              "created_date": "2022-08-12 04:03:08",            
          },
          {
              "first_name": "john",
              "sport": "",
              "created_date": "2022-08-01 23:00:46",
              
          },
           {
              "first_name": "robot",
              "sport": "cricket",
              "created_date": "2022-08-10 23:00:46",
              
          },
          {
              "first_name": "roy",
              "sport": "",
              "created_date": "2022-07-31 23:00:46",
              
          },
  ]
  
  
      content.sort(function compare( a, b ) {
              if ( a.sport &lt; b.sport || (new Date(a.created_date) &lt; new Date(b.created_date))){
                  return 1;
              }
              if ( a.sport &gt; b.sport || (new Date(a.created_date) &lt; new Date(b.created_date)) ){
                  return -1;
              }
              return 0;
          });
          
  console.log(content)</code></pre>
  </div>
  </div>
  </p>
  <p>Attached the expected result</p>
  <p>expected result</p>
  <pre><code>var content =  [
           {
              &quot;first_name&quot;: &quot;robot&quot;,
              &quot;sport&quot;: &quot;cricket&quot;,
              &quot;created_date&quot;: &quot;2022-08-10 23:00:46&quot;,
              
          },
          
            {
              &quot;first_name&quot;: &quot;musk&quot;,
              &quot;sport&quot;: &quot;cricket&quot;,
              &quot;created_date&quot;: &quot;2022-08-12 04:03:08&quot;,            
          },
          {
              &quot;first_name&quot;: &quot;roy&quot;,
              &quot;sport&quot;: &quot;&quot;,
              &quot;created_date&quot;: &quot;2022-07-31 23:00:46&quot;,
              
          },
          {
              &quot;first_name&quot;: &quot;john&quot;,
              &quot;sport&quot;: &quot;&quot;,
              &quot;created_date&quot;: &quot;2022-08-01 23:00:46&quot;,
              
          },
         
  ]
  </code></pre>
  <p>can anyone help me with what i am doing wrong in snippet</p>