PHP按包含ID的另一个数组对多维数组进行排序


Hi, can anyone help me to sort a multidimensional array by another array?

Array 1:

Array(
    [0] => Array( 
        'id' => '58e9f01ff291c'
    ),
    [1] => Array( 
        'id' => '58e9f0590d6c0' 
    ),
    [2] => Array(
        'id' => '58ea5274219ac
    )
)


Array 2:

Array('58e9f0590d6c0', '58ea5274219ac', '58e9f01ff291c')

The second array contains the IDs of the first array and I would like to sort the first array by the IDs in the second array. How can I do this?

Best wishes and thanks for any help
Canned


Update:
I figured it out:

$return = array();
foreach($array2 as $sortId) {
    foreach ($array1 as $subKey => $subArray) {
        if ($subArray['id'] == $sortId) {
            $return[] = $array1[$subKey];
            break;
        }
    }
}