How does a doctor fix testicular torsion?

Rotation, surgery. Non-surgical correction can sometimes be done by manually rotating the testicle in the opposite direction (outward, towards the thigh). If this is initially unsuccessful, a forced manual rotation in the other direction may correct it. Manual detorsion is successful in 26.5% to 80% of patients. This is a surgical emergency needing prompt manual or surgical rx. But with good chance of success.
Surgery to put 2-3. Through open surgery under proper anesthesia, surgeon puts 2-3 non-absorbable stiches to fix the testis to the dependent part of the sac corresponding to the testis so to prevent recurrent torsion.