3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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']);
Output for 5.6.30
array(11) { [0]=> array(2) { ["id"]=> string(1) "1" ["weight"]=> int(1) } [1]=> array(2) { ["id"]=> string(1) "2" ["weight"]=> int(2) } [2]=> array(2) { ["id"]=> string(1) "3" ["weight"]=> int(3) } [3]=> array(2) { ["id"]=> string(1) "4" ["weight"]=> int(4) } [4]=> array(2) { ["id"]=> string(1) "5" ["weight"]=> int(5) } [5]=> array(2) { ["id"]=> string(1) "6" ["weight"]=> int(6) } [6]=> array(2) { ["id"]=> string(1) "7" ["weight"]=> int(7) } [7]=> array(2) { ["id"]=> string(1) "8" ["weight"]=> int(8) } [8]=> array(2) { ["id"]=> string(1) "9" ["weight"]=> int(9) } [9]=> array(2) { ["id"]=> string(2) "10" ["weight"]=> int(10) } [10]=> array(2) { ["id"]=> string(2) "11" ["weight"]=> int(11) } }