Re: Sort with -Infinity fails

• To: mathgroup at smc.vnet.net
• Subject: [mg73870] Re: [mg73822] Sort with -Infinity fails
• From: János <janos.lobb at yale.edu>
• Date: Fri, 2 Mar 2007 06:36:20 -0500 (EST)
• References: <200703011117.GAA28248@smc.vnet.net>

```On Mar 1, 2007, at 6:17 AM, Tom Aldenberg wrote:

> Dear MathGroup,
>
> Minus Infinity (-Infinity) is smaller than -8, but Sort does not
> sort it as
> expected.
> Is there a Real minus Infinity?
>
>
> In[75]:=
>       -Infinity < -8
> Out[75]=
>       True
>
> In[76]:=
>       Sort[{-Infinity, -8, 5}]
> Out[76]=
>       {-8, 5, -=B0}
>
>
> Regards,
>
> Tom Aldenberg
>
> ______________________________________________________________________=

> ______
>
> DISCLAIMER:  http://www.rivm.nl/disclaimer.htm
>

Well, being a newbie I looked up sort in the Help.  I found that
Sort  follows the "canonical Order" - whatever that is.  Appendix says:

"Integers, rational and approximate real numbers are ordered by their =

numerical values"

"Symbols are ordered according to their names, and in the event of a
tie, by their contexts"

Lets have the following list:

In[50]:=
lst = {Infinity, -Infinity,
-8, 5}

In[54]:=
Out[54]=
{DirectedInfinity,
DirectedInfinity, Integer,
Integer}

So, if you want to have the "normal" result you have to use a
different ordering in Sort to force a numerical value on
DirectedInfinity.

In[53]:=
Sort[lst, Less]
Out[53]=
{-Infinity, -8, 5, Infinity}

J=87nos

========================
"I think I may need a bathroom break? Is this possible?" --G.W.Bush
http://news.bbc.co.uk/2/hi/americas/4249646.stm

```

• Prev by Date: Re: Regression
• Next by Date: Hilbert Transform problems
• Previous by thread: Re: Sort with -Infinity fails
• Next by thread: RE: Sort with -Infinity fails