In an inert solvent, retention of configuration of the substrate is observed, whereas in the presence of certain other compounds, like pyridine for instance, inversion of configuration is observed.
This is because the pyridine complexes with the HCl formed initially, and this makes the chloride ion free, and the chloride attacks from the back side of the leaving group (SO2 in this case)
In the first case, after elimination of HCl, the Cl directly attacks the electrophilic carbon from the same side as the leaving group.