improves vertical sort
fix bug when stacking more than two modules