title: Sort array by two object properties using anonymous function
body: <p>I have the following array:</p>
  
  <pre><code>Array
  (
      [0] =&gt; stdClass Object
          (
              [timestamp] =&gt; 1
              [id] =&gt; 10
          )
  
      [1] =&gt; stdClass Object
          (
              [timestamp] =&gt; 123
              [id] =&gt; 1
          )
  
      [2] =&gt; stdClass Object
          (
              [timestamp] =&gt; 123
              [id] =&gt; 2
          )
  
  ) 
  </code></pre>
  
  <p>I'm currently using the following code to sort the array by the timestamp property:</p>
  
  <pre><code>function sort_comments_by_timestamp(&amp;$comments, $prop)
  {
      usort($comments, function($a, $b) use ($prop) {
          return $a-&gt;$prop &lt; $b-&gt;$prop ? 1 : -1;
      });
  }
  </code></pre>
  
  <p>How can I also sort id by <code>id</code> descending when timestamp is the same?</p>