some code added to 'sortEdgesPerCube' function