ENH factor out sparse partition
ENH factor sparse swap
ENH less index computation