my @sorted = ((sort {$order{$a} <=> $order{$b}} grep {exists $order{$_}} @to_be_ordered), grep {not exists $order{$_}} @to_be_ordered);