Insert into sorted array rather than sorting each time