So in the derivation of the Potential energy of a dipole due to an external field, we consider a dipole with charges $q_1= +q$ and $q_2= –q$ placed in a uniform external electric field. We know that in a uniform electric field, the dipole experiences no net force but it experiences a torque $τ$ given by
$$\vecτ = \vec p×\vec E$$
which will tend to rotate it. Now here's the tricky part. Suppose an external torque $τ _{ext}$ is applied in such a manner that it just neutralises this torque and rotates it in the plane of paper from angle $θ_0$ to angle $θ_1$ at an infinitesimal angular speed and without angular acceleration. The amount of work done by the external torque
$$W= \int \:τ\left(\theta \right)d\theta =\int \:\left(pEsin\theta \right)d\theta $$
$$W=pE\left(cos\theta_0 -cos\theta_1 \right)$$
if $\theta_0=\pi/2$ then and $\theta_1=\theta$
$$W=-pEcos\theta$$
My concern is if the torque due to an external electric field (the conservative force) is given by $\:pEsin\theta \:$, and if an external torque is applied to neutralise this torque, shouldn't its value be $-\:pEsin\theta \:$ in the derivation. I know the final answer is correct but I am also sure my 2 assumptions that (1) the external torque is negative of the conservative force and that (2) potential energy is work done by the external force in setting up a configuration (in this case rotating the dipole) are both correct. I think rotational dynamics is where I got something wrong