MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Sorting complex points


OT wrote:

> I'm trying to sort lists of random complex points on the unit circle
> using their angles as criterion to sort them: I mean, if
> z=Cos[a]+I*Sin[a] and w=Cos[b]+I*Sin[b]( 0<=a,b<2*Pi ),
> I want z<w if a<b;
> 
> how can i do that?

Hi, try


MyArg[x_] := Mod[Arg[x], 2 Pi]

list={0.625162 + 0.835834 I,0.502244 + 0.43736 I}

sortedlist = Sort[list, MyArg[#1] < MyArg[#2] &]


Regards,
Marcus

-- 
Kant was right: The mind imposes order.
It also tells you how much to tip. -- W. Allen


  • Prev by Date: Problems with Derivative, Piecewise, Assuming
  • Next by Date: Re: Newly Released Mathematica 5.1 Delivers Unmatched Performance for Handling Data
  • Previous by thread: Re: Sorting complex points
  • Next by thread: Re: Sorting complex points