You can take the Circumencia Vesuvia (sp?) train from the main train station in Naples. It's about a 45 minute train ride and it runs every 20 minutes or so. It's the same train that stops at Vesuvius. The train station in Sorrento is within easy walking distance of the main piazza area (5 minutes or so).
Definitely be prepared for pickpockets on the train. My friend had his wallet in his front pocket and it was taken as he stepped on to the train amid a crowd of people. My other friend's backpack was unzipped on the train at the same time her hubby's pocket was being picked! They work in pairs or small groups. Just be smart and you'll be fine.