title: Sorting array after firstName and lastName, javascript
body: <p>Currently I am sorting an array on firstName.</p>
  <pre><code>currentUsers = currentUsers.sort(function(a, b) {
      if (a.firstName &gt; b.firstName) {
          return 1;
      } else if (a.firstName &lt; b.firstName) {
          return -1;
      }
  };
  </code></pre>
  <p>But I would like to have the lastName sorted as well. So that Bob Anderson would be sorted above Bob Bobson. I looked at another question here on stackoverflow which suggested that I should add:</p>
  <pre><code>currentUsers = currentUsers.sort(function(a, b) {
      if (a.firstName &gt; b.firstName) {
          return 1;
      } else if (a.firstName &lt; b.firstName) {
          return -1;
      }
  
      if (a.lastName &gt; b.lastName) {
          return 1;
      } else if (a.lastName &lt; b.lastName) {
          return -1;
      } else {
          return 0;
      }
  };
  </code></pre>
  <p>//Edit
  The problem I have is that the sorting keeps sorting on every letter in firstName. How would I only sort on the first letter of firstName and then move on to the lastName?</p>