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>*Reply-to*: murray at math.umass.edu*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... Clicking the More hyperlink takes you to The HelpBrowser help about Sort. Under the Further Examples there, you'll see, for example: Sort[{-8, -5, 6, 9}, #1^2 < #2^2 & ] So for your situation: 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

**References**:**Sorting complex points***From:*OT <montoz@iol.it>