$sorted = [];
foreach($order as $oitem) {
foreach ($unsorted as $key => $uitem) {
if($oitem['course_id'] == $uitem['course_id']) {
$sorted[] = $uitem;
unset($unsorted[$key]);
break;
}
}
}
foreach ($unsorted as $uitem) {
$sorted[] = $uitem;
}