This is the part where you need to do a foreach on the two order arrays.  Or even better...since there's only two arrays, I would make it explicit, so it's more readable, ie:

$newOrderNumber = array_search($oldOrderNumber, $newFormOrder);
$element->setVar('ele_order',$newOrderNumber);
$newListOrderNumber = array_search($oldOrderNumber, $newListOrder);
$element->setVar('ele_list_order',$newListOrderNumber);