I have this array:
$categories = array(1,19,4,33,10,7,12);
And this array:
$order = array(33,12,50,19,4,1,100,18,9,2,7);
What I want is for $categories
to be sorted in the way that is prefined
in $order
. So the result I need would be:
$categories_sorted = array(33,12,19,4,1,7,10);
As you may have noticed, 10
is not in $order
. This is because the $order
array never has all categories in it, only the most important ones. The $categories_sorted
array should always contain all values from $categories
, even if they are not in $sorted
.