Work done by the force of gravity, W = mgh.
Where h = difference in height of initial and final positions of the object.
According to question, the initial and final positions of the object lie in the same horizontal line. So h = 0.
∴ Work done W = mg × 0 = 0