3v4l.org

run code in 300+ PHP versions simultaneously
<?php $promos = [ '1' => ['id' => '1', 'weight' => 1], '2' => ['id' => '2', 'weight' => 2], '3' => ['id' => '3', 'weight' => 3], '4' => ['id' => '4', 'weight' => 4], '5' => ['id' => '5', 'weight' => 5], '6' => ['id' => '6', 'weight' => 6], '7' => ['id' => '7', 'weight' => 7], '8' => ['id' => '8', 'weight' => 8], '9' => ['id' => '9', 'weight' => 9], '10' => ['id' => '10', 'weight' => 10], '11' => ['id' => '11', 'weight' => 11], ]; $cr['promos'] = [ '1' => ['id' => '1', 'weight' => 1], '2' => ['id' => '2', 'weight' => 2], '3' => ['id' => '3', 'weight' => 3], '4' => ['id' => '4', 'weight' => 4], '5' => ['id' => '5', 'weight' => 5], '6' => ['id' => '6', 'weight' => 6], '7' => ['id' => '7', 'weight' => 7], '8' => ['id' => '8', 'weight' => 8], '9' => ['id' => '9', 'weight' => 9], '10' => ['id' => '10', 'weight' => 10], '11' => ['id' => '11', 'weight' => 11], ]; $promo_weights = array_column($promos, 'weight', 'id'); array_multisort($promo_weights, SORT_ASC, $cr['promos']); var_dump($cr['promos']);

preferences:
45.93 ms | 402 KiB | 5 Q