Dundee are back in the Scottish Premiership after beating Dumbarton on the final day of the Championship season.