update sorted array. pointer operation is required