Can you entmod lines that don't reside in correct orientation CW/CCW and then join them?
I don't know which is the correct direction (CW/CCW) ...
the segments themselves do not have a CW/CCW direction ...
... the problem is only to join segments that touch each other,
and that
have to be put in order ...
reversing those that touch either both
at point p10 or both at point p11 ...
the sequence must be p10 p11, p10 p11, p10 p11 ...
They
must be consecutive segments ...
I haven't tested vovka's code yet, but I'm sure it works...
my code works and also works with
segment groups that define more shapes ...
if you open the attached dwg there are 4 shapes,
made up of often oppositely oriented segments ...
with one command, all segments are all merged