I'm not sure array_multisort()
can help you here, as the contents of A aren't in any obvious order.
I'd do it by indexing B by waypoint purely for efficiency, and then creating a new $ordered
array from A:
$indexed = array();
foreach($b as $array) {
$indexed[$array['waypoint_id']] = $array;
}
$ordered = array();
foreach($a as $waypoint) {
$ordered[] = $indexed[$waypoint];
}