title: sort dom elements on the basis of href attribute in JS
body: <p>I have DOM elements as shown below. I want to sort it on the basis of href attribute.  </p>
  
  <p>This is what I have tried in <strong>JS</strong> but more need to be done.</p>
  
  <pre><code>document.addEventListener("DOMContentLoaded", function () {
      let elems = Array.from(document.querySelectorAll(".house-senate a"));
      elems.sort((a, b) =&gt; a.textContent.localeCompare(b.textContent));
  
  });
  </code></pre>
  
  <p><strong>Problem Statement:</strong></p>
  
  <p>I am wondering what JS code I need to add so that it sorts everything on the basis of href attributes. </p>