MathGroup Archive 1999

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

Search the Archive

Re: Sort


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


  • Prev by Date: Memory bloat -- what have I done?
  • Next by Date: Re: Sort
  • Previous by thread: RE: Sort
  • Next by thread: Re: Sort