Re-implement sorting plus modify SPH calculations