def cmplx_sort(p):
 p = asarray(p)
 if iscomplexobj(p):
  indx = argsort(abs(p))
 else:
  indx = argsort(p)
 return (take(p, indx, 0), indx)

def cmplx_sort ( p ) : p = asarray ( p ) if iscomplexobj ( p ) : indx = argsort ( abs ( p ) ) else : indx = argsort ( p ) return ( take ( p , indx , 0 ) , indx )
sort roots based on magnitude .