Skip to content

Bookmarked https://buttondown.email/cassidoo/archive/reality-is-one-of-the-possibilities-i-cannot/. PHP okay, too? function reorder($a, $b) …

Bookmarked https://buttondown.email/cassidoo/archive/reality-is-one-of-the-possibilities-i-cannot/.

PHP okay, too?

function reorder($a, $b) {

    $arr = array_combine($b, $a);

    ksort($arr);

    return $arr;

}

Given an array of objects A, and an array of indexes B, reorder the objects in array A with the given indexes in array B.