Re: RE: Sort
- To: mathgroup at smc.vnet.net
- Subject: [mg19278] Re: [mg19188] RE: Sort
- From: "Tomas Garza" <tgarza at mail.internet.com.mx>
- Date: Thu, 12 Aug 1999 01:24:29 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Ersek, Ted R [ErsekTR at navair.navy.mil] wrote: > I discovered something related behavior > Hermann Meier noted about Sort. > ------------------- > Sort, Union, Intersection, and Complement each > return a "sorted" list in the examples below, but > the lists aren't sorted according to their > numeric value. > > > In[1]:= > Sort[{0,-3,-Pi,5,Pi/2}] > > Out[1]= > {-3, 0, 5, -Pi, Pi/2} > > > In[2]:= > Union[{0,-3,-Pi,5,Pi/2}] > > Out[2]= > {-3, 0, 5, -Pi, Pi/2} > > > In[3]:= > Intersection[{-3,5,-Pi},{-3,0,5,-Pi,Pi/2}] > > Out[3]= > {-3, 5, -Pi} > > > In[4]:= > Complement[{-3,0,5,-Pi,Pi/2},{0,Pi/2,6,8}] > > Out[4]= > {-3, 5, -Pi} > > ----------------------- > > I am pretty sure the lists above are sorted > by the method described in Section A.3.9 in > The Mathematica Book. I think it is best to start by explaining that Pi is a symbol: In[1]:= Head[Pi] Out[1]= Symbol One should not confuse Pi with Pi//N: In[2]:= Sort[{0, -3, -Pi // N, 5, Pi/2 // N}] Out[2]= {-3.14159, -3, 0, 1.5708, 5} The result here agrees with what one would expect if all the elements to be sorted were numbers. No strange results thus far. Tomas Garza Mexico City