title: Cannot sort collection by relationship field
body: <p>I have a table called <code>posts</code> that stores all the post types, each post can have multiple and dynamic meta values, so I have the <code>post_meta</code> table which handle all of this.</p>
  <p>The <code>post_meta</code> table have the following structure:</p>
  <pre><code>id | post_id |  meta_key | meta_value
  </code></pre>
  <p>This is the structure of the <code>posts</code> table:</p>
  <pre><code>id | content | type | created_at | updated_at | deleted_at
  </code></pre>
  <p>I need to order the post with the type <code>section</code>, so what I did so far is this:</p>
  <pre><code>$sections = Post::with('meta')-&gt;where([
      'type' =&gt; 'section',
      'language' =&gt; 'it',
      'status' =&gt; 'published',
  ])-&gt;get();
  
  $sections-&gt;sortBy(function ($sec) {
  
      return $sec-&gt;getMeta('order')-&gt;meta_value;
  });
  </code></pre>
  <p>where <code>getMeta</code> is a custom method that I have added within the <code>Post</code> model:</p>
  <pre><code>public function getMeta(string $metaKey)
  {
      $key = array_search($metaKey, array_column($this-&gt;meta-&gt;toArray(), 'meta_key'));
      return $key !== false ? $this-&gt;meta[$key] : null;
  }
  </code></pre>
  <p>The issue is that I doesn't get any ordering, what I'm doing wrong?</p>
  <p>Current <code>datasets</code>:</p>
  <pre><code>id | type
   1   section
   2   section
   3   section
  
  id | post_id | meta_key  | meta_value
   1     1        order       0
   2     2        order       2
   3     3        order       1
  </code></pre>
  <p>I should get this sequence: <code>1, 3, 2</code> instead of <code>1, 2, 3</code></p>