This is because there is no relationship between the item id and the price when you are collecting the posted data. Do the changes as below.
Change the sale_price to below to include the item id
<input name="sale_price[<?php echo get_the_id(); ?>]" type="text" value="<?php echo get_post_meta(get_the_id(), "_sale_price", true); ?>" />
Then change the loop for collecting the data as below.
foreach ($ids as $id){
update_post_meta($id,'_sale_price', $sales[$id]);
}