3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ 65 => [ ["p" => 234, "sp" => 234], ["p" => 53, "sp" => 5], ["p" => 530, "sp" => 5], ] ]; $col = 'p'; // set the column you want to order on $column = array_column($arr[65], $col); // get all p values asort($column); // sort values ascending but keep keys $arr[65] = $arr[65][array_key_first($column)]; // replace key "65" array by array-value with key containing lowest "p" var_dump($arr);
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array(1) { [65]=> array(2) { ["p"]=> int(53) ["sp"]=> int(5) } }

preferences:
115.85 ms | 1373 KiB | 4 Q