Re: Sort

*To*: mathgroup at smc.vnet.net*Subject*: [mg19172] Re: Sort*From*: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>*Date*: Tue, 10 Aug 1999 02:52:38 -0400*Organization*: Universitaet Leipzig*References*: <7odl77$7of@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hermann Meier wrote: > > Sort is not reliable. Try the following (Mathematica Version 4): > > In[1]:= > Sort[{0, -Sqrt[2], 5}] > Hi Hermann, thats nonsense. If you cant only sort the same kind of things. There is no rule how to sort a train, a airplane and a toaster. In you example you try to sort integers and symbolic expressions like Sqrt[5]. Sort[] work as expected and create the "normal order" of expressions i. e. numbers first, variables, functions .. If you like to sort a list of numbers with some symbolic expressions like Sqrt[2], E, Pi .. you can simply use the second sort argument and Sort[{0, -Sqrt[2], 5}, N[#1] < N[#2] &] will work as you expect. Hope that helps Jens