title: Sorting an Array of Objects in PHP In a Specific Order
body: <p>I have two arrays in PHP. The first array ($author_array) is comprised of user_ids in a particular order, like so: (8, 1, 6)</p>
  
  <p>The second array ($user_results) is comprised of an array of objects like so:</p>
  
  <pre><code>Array
  (
      [0] =&gt; stdClass Object
          (
              [ID] =&gt; 1
              [user_login] =&gt; user1
          )
      [1] =&gt; stdClass Object
          (
              [ID] =&gt; 6
              [user_login] =&gt; user6
          )
      [2] =&gt; stdClass Object
          (
              [ID] =&gt; 8
              [user_login] =&gt; user8
          )
  )
  </code></pre>
  
  <p>I'd like to "sort" the second array so it's in this order, which matches the order of the values in the first array of (8, 1, 6). So it'd look like this:</p>
  
  <pre><code>Array
  (
      [0] =&gt; stdClass Object
          (
              [ID] =&gt; 8
              [user_login] =&gt; user8
          )
      [1] =&gt; stdClass Object
          (
              [ID] =&gt; 1
              [user_login] =&gt; user1
          )
      [2] =&gt; stdClass Object
          (
              [ID] =&gt; 6
              [user_login] =&gt; user6
          )
  )
  </code></pre>
  
  <p>I'm weak on data structures. How could I do this? :-)</p>
  
  <p>Thanks in advance for your help!</p>
  
  <p>-Bob</p>