3v4l.org

run code in 300+ PHP versions simultaneously
<?php $amsterdam = [ 65 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'boo', 'price' => 100 ] ], 173 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'hoo', 'price' => 2500 ] ], ]; $prague = [ 132 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'boo', 'price' => 2100 ] ], 956 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'hoo', 'price' => 2500 ] ], ]; $lisboa = [ 175 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'boo', 'price' => 6500 ] ], 64 => [ 'table' => 'Object', 'something' => false, 'data' => [ 'foo' => 'hoo', 'price' => 20 ] ], ]; $cities = [ 'amsterdam' => $amsterdam, 'prague' => $prague, 'lisboa' => $lisboa ]; $map_prices = function($n) { $reduce_smallest_price = function($carry, $item) { return $item['data']['price'] < $carry ? $item['data']['price'] : $carry; }; return array_reduce($n, $reduce_smallest_price, INF); }; $cities_price = array_map($map_prices, $cities); asort($cities_price); uksort($cities, function($a, $b) { global $cities_price; return strnatcmp($cities_price[$a], $cities_price[$b]); }); print_r($cities_price); print_r($cities);

preferences:
25.58 ms | 409 KiB | 5 Q