Debug : Sort overlapping and horizontal/vertical switching