function ret=crootssort(w)

# This function sorts complex numbers such that
# 1) All the pure reals come first and are sorted.
# 2) All complex numbers are sorted by the regular sort. 

iscol=iscolumn(w);

q=sort(w(imag(w)==0));
q1=sort((w(imag(w)!=0)));

if(iscol)
 ret=[q' q1']';
else
  ret=[q q1];
endif
endfunction
