Sort collection by custom order in Eloquent : <p>I have an array of ID's as follows:</p>

<pre><code>$ids = [5,6,0,1]
</code></pre>

<p>Using Eloquent I am able to search for these Id's using the <code>-&gt;whereIn('id', $ids)</code> function. This as expected will return the results in the ascending order by Id,  is there a way I can return the results on the order the array is in? alternatively whats the easiest way to convert the collection in the order of the <code>$ids</code> array?</p>
