Create sortedmean and write the startup code