       Re: Sorting complex points

• To: mathgroup at smc.vnet.net
• Subject: [mg55891] Re: [mg55874] Sorting complex points
• From: Murray Eisenberg <murray at math.umass.edu>
• Date: Sat, 9 Apr 2005 03:55:30 -0400 (EDT)
• Organization: Mathematics & Statistics, Univ. of Mass./Amherst
• References: <200504080537.BAA25196@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```   ?Sort
Sort[list] sorts the elements of list into canonical
order. Sort[list, p] sorts using the ordering function \
p. More...

Sort.  Under the Further Examples there, you'll see, for example:

Sort[{-8, -5, 6, 9}, #1^2 < #2^2 & ]

sortByArg[z_List] := Sort[z,  Arg[#1] < Arg[#2] &]

For example:

myzs =  {-1 + 9I, 0.5I, -I, -4, 2 + 3I};

sortByArg[myzs]
{-I, 2 + 3*I, 0.5*I, -1 + 9*I, -4}

OT wrote:
> Hi all,
>
> 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?
>
> I tried to define Angle[z] as a piecewise funztion, but I still don't
> understand how to use it with Sort...
>
> Thanks,
>
> andrea
>
>

--
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

```

• Prev by Date: Re: Version differences in Integrate with Min[] in the integrand
• Next by Date: Re: Why are there no spaces in my title?
• Previous by thread: Sorting complex points
• Next by thread: Re: Sorting complex points