Re: Sort
- To: mathgroup at smc.vnet.net
- Subject: [mg19196] Re: [mg19152] Sort
- From: BobHanlon at aol.com
- Date: Tue, 10 Aug 1999 02:52:51 -0400
- Sender: owner-wri-mathgroup at wolfram.com
lst = {0, -Sqrt[2], 5}; Sort[lst] {0, 5, -Sqrt[2]} Sort[N[lst]] {-1.41421, 0., 5.} However, using N changes the form of the expressions. If you don't like the default Sort criteria, you can define a different Sort criteria and leave the form of the expressions alone. Sort[lst, #1 < #2 &] {-Sqrt[2], 0, 5} Bob Hanlon In a message dated 8/6/99 12:56:53 AM, hmeier at webshuttle.ch writes: >Sort is not reliable. Try the following (Mathematica Version 4): > >In[1]:= >Sort[{0, -Sqrt[2], 5}] > >Out[1]= >{0, 5, -Sqrt[2]} > >In[2]:= >Sort[{0., -Sqrt[2], 5}] > >Out[2]= >{0., 5, -Sqrt[2]} > > >One has to apply N to the list to get the correct result: > >In[3]:= >Sort[N[{0., -Sqrt[2], 5}]] > >Out[3]= >{-1.414213562, 0., 5.} >