3v4l.org

run code in 300+ PHP versions simultaneously
<?php $allOptions = [ ["clID" => 171], ["clID" => 191], ["clID" => 131], ["clID" => 101], ["clID" => 201], ["clID" => 181], ["clID" => 99], // not in regOptions ["clID" => 129], // not in regOptions ["clID" => 139], ]; $regOptions = [ ["order" => 1, "optID" => 131], ["order" => 2, "optID" => 191], ["order" => 3, "optID" => 181], ["order" => 4, "optID" => 139], ["order" => 5, "optID" => 101], ["order" => 6, "optID" => 201], ["order" => 7, "optID" => 171], ]; $priority = array_column($regOptions, 'order', 'optID'); array_multisort( array_map(fn($v) => $priority[$v['clID']] ?? PHP_INT_MAX, $allOptions), $allOptions ); var_export($allOptions);

preferences:
29.76 ms | 407 KiB | 5 Q