title: Javascript sort array join two id
body: <p>I want to join the "ReplyID" and personality and sort them. Example "Reply ID" 16 data; "Id" under 16</p>
  
  <pre><code>dataPathRep.sort((a,b) =&gt; (b.ReplyIDId == a.ReplyIDId) ? (b.Id&lt;a.Id):b.ReplyIDId &lt; a.ReplyIDId)
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>dataPathRep.sort(function (a, b) {
      if (nullif(a.ReplyIDId, "0") == "0") {
          return a.Id;
      } else if (nullif(a.ReplyIDId, "0") == "0") {
          return b.Id;
      } else if (b.ReplyIDId == a.ReplyIDId) {
          a.Id &lt; b.Id;
      } else {
          a.ReplyIDId &lt; b.ReplyIDId;
      }
  });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/4MarU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4MarU.png" alt="enter image description here"></a>
  [![enter image description here][2]][2]</p>