Can the complex number be sorted with real part then imaginary, rather than with magnitude and angle? This could be useful with geometry situation.

```
# Find flipline inside a bounding box
# bb=bounding box defined by two complex coordinates (left-bot & right-top)
# c=line single point as complex number, da=line angle
# Prerequisite is that the point c is inside the bounding box bb
function [fl]=flipline(bb,c,da)
bbo=bb-c;
d=real(bbo(2)-bbo(1));
n=[bbo(1); bbo(2)-d; bbo(2); bbo(1)+d; bbo(1)];
v=n(2:end)-n(1:end-1);
p1=complex(cosd(da),sind(da));
s1=conj(v(1:end)); s2=conj(p1);
s=imag(n(2:end).*s1)./imag(s1.*p1);
t=imag((p1-n(1:end-1)).*s2)./imag(s2.*v(1:end));
cs=(t>4*eps)&(t-1<4*eps);
if (sum(cs)<2),
fl=[];
return;
end;
fl=p1*s(cs)+c;
[rp,i]=sort(real(fl));
fl=complex(rp,imag(fl(i)));
endfunction
```

This case it need sorted with returned index i and then assembled again with complex().

Testing the function:

```
octave:171> bb=[-2-2i; 2+2i]; p=complex(8*rand()-4,8*rand()-4), a=180*rand()-90, ln=flipline(bb,p,a), if (length(ln)>0), plot(ln); else clf; end; d=real(bb(2)-bb(1)); n=[bb(1); bb(2)-d; bb(2); bb(1)+d; bb(1)]; line(real(n),imag(n));
p = 3.5601 - 1.1169i
a = -24.918
ln =
-2.0000 + 1.4660i
2.0000 - 0.3922i
```