Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


  • Prev by Date: Re: Fw: greek symbols in eps files
  • Next by Date: Re: How to Extract a common factor from a Sum
  • Previous by thread: RE: Strange behavior of Sort
  • Next by thread: Re: Re: Strange behavior of Sort