Re: Strange behavior of Sort

• To: mathgroup at smc.vnet.net
• Subject: [mg12997] Re: [mg12941] Strange behavior of Sort
• From: Sean Ross <seanross at worldnet.att.net>
• Date: Sun, 28 Jun 1998 02:52:19 -0400
• References: <199806240744.DAA03200@smc.vnet.net.> <3591C786.6C9F@worldnet.att.net> <359259A6.52C7D61@siu.edu>
• Sender: owner-wri-mathgroup at wolfram.com

```Edward Neuman wrote:
>
> Sean Ross wrote:
>
> > Edward Neuman wrote:
> > >
> > > In Mathematica 3.0:
> > >
> > > In[5]:=
> > > li={1/Sqrt[2], 1, -Sqrt[2]};
> > >
> > > In[7]:=
> > > Sort[li]//InputForm
> > >
> > > Out[7]//InputForm=
> > > {1, 1/Sqrt[2], -Sqrt[2]}
> > >
> > > Sort doesn't work properly on this list.
> > >
> > > Edward Neuman
> >
> > What would you like it to do instead?  I think that
> > {1,1/Sqrt[2],-Sqrt[2]} is in proper order from greatest to smallest
>
>   Sean:
>
>
> In[2]:=
> Sort[ {1, 1/Sqrt[2], -Sqrt[2]} ]//InputForm
>
> Out[2]//InputForm=
> {1, 1/Sqrt[2], -Sqrt[2]}
>
> By default, Sort rearranges members of the list so that they are in the
> ascending order.
>
> Regards,
>
> Edward Neuman

OK, I see your point now.  A more clear way to state it would be:

In[2]:=
Sort[{1,1/Sqrt[2.],-Sqrt[2.]}]
Out[2]=
{-1.41421,0.707107,1}

In[3]:=
Sort[{1,1/Sqrt[2],-Sqrt[2]}]
Out[3]=
{1,1/Sqrt[2],-Sqrt[2]}

It seems clear that Sort does not convert the members of the list into
Real numbers in order to Sort them.  I wonder what the criteria is for
unevaluated expressions?

```

• Prev by Date: Re: Inconsistencies in pattern matching.
• Next by Date: Mathlink on Windows and Cygwin
• Previous by thread: Strange behavior of Sort
• Next by thread: Re: Strange behavior of Sort