Move sparse array logic into each().