sort_by_key in update_b