ng-repeat orderBy - Display items as values appear in an array
<p>In my directive I receive through the scope an array of values which is not sorted and I would like to have it sorted with ng-repeat. Reason is there is no a special criteria for the sorting, I just want to ensure some labels are displayed in the order I desire, so a hand sorting in the link function by indexOf and splice doesn't look really good. </p>

<p>I wonder if creating a new array with the order I desire the labels displayed could be applied somehow in ng-repeat.</p>

<p>An example may help to understand my point.</p>

<p>My directive</p>

<p><code>
$scope.unsortedLabels // ['foo1', 'foo2', 'foo3'] Array of labels I receive from parent directive
$scope.desiredLabelsOrder = ['foo3', 'foo1', 'foo2'] // The order I want the labels displayed</code></p>

<p>My template</p>

<p><code>&lt;li ng-repeat="label in unsortedLabels | orderBy: ?? &gt;&lt;/li&gt;"</code></p>

<p>How can I use the desiredLabelsOrder array to display the foo3 label first, then foo1 and foo2 last?</p>

<p>Thank you</p>