I'm looking for a way to change the order of an array by keys by using a different array which contains the keys and the new index of this key. The order will be dynamic so ASC or DESC sorting will not work.
Is there a function to sort an array this way?
the original array(which need to be rearranged)
{
4 => 'this should move to fifth place',
2 => 'this should not move',
5 => 'this should move to end of the array',
9 => 'this should move to fourth place',
77 => 'this should move to beginning',
10 => 'this should move to third place',
}
array sortIndex(the array with the new order)
{
key of other array => index/order,
//
4 => 5,
77 => 1,
2 => 2,
9 => 4,
10 => 3,
5 => 6,
}