Re: Strange behavior of Sort
- To: mathgroup at smc.vnet.net
- Subject: [mg12954] Re: Strange behavior of Sort
- From: Arnoud Buzing <arnoudb>
- Date: Sun, 28 Jun 1998 02:51:45 -0400
- Organization: Wolfram Research, Inc.
- References: <6mqfeo$3ib@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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 Try using: Sort[li,Less] For example: In[9]:= l1 = {1, -Sqrt[2], Exp[-Sqrt[5]], Prime[20], -Sin[1]} -Sqrt[5] Out[9]= {1, -Sqrt[2], E , 71, -Sin[1]} In[10]:= Sort[l1,Less] -Sqrt[5] Out[10]= {-Sqrt[2], -Sin[1], E , 1, 71} In[11]:= Sort[l1] -Sqrt[5] Out[11]= {1, 71, -Sqrt[2], E , -Sin[1]} --- Arnoud