The non-uniform rotation of the Sun and its magnetic field