N = 3e6;
r = complex (rand (N,1), rand (N,1));
## Use sortrows, N calculations of abs and angle, but 4*N memory requirements
tic;
[~,j] = sortrows ([abs(r), angle(r)]);
rs1=r(j);
bm1 = toc
## sort, N*log2(N) calculations of abs and possibly angle, 2*N memory
tic;
rs2=sort(r);
bm2 = toc
isequal(rs1,rs2)