Work done by gravitational force W = mgh
Where h = Difference in the heights of initial and final positions of the object.
Here both the initial and final positions are on the same horizontal line.
So there is no difference in height i.e., h = 0.
∴ work done W = mg × 0 = 0.