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

MathGroup Archive 2007

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

Search the Archive

Re: Sort with -Infinity fails

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73892] Re: Sort with -Infinity fails
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Fri, 2 Mar 2007 06:48:18 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <es6d0l$rmr$1@smc.vnet.net>

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, -â??}

Negative infinity is not a number but an expression:

In[1]:=
Head /@ {-Infinity, -8, 5}

Out[1]=
{DirectedInfinity,Integer,Integer}

In[2]:=
FullForm[-Infinity]

Out[2]//FullForm=
DirectedInfinity[-1]

Try your own ordering function to force the numerical evaluation as a 
real. For instance,

In[3]:=
Sort[{-Infinity, -8, 5}, #1 < #2 & ]

Out[3]=
{-Infinity, -8, 5}

Regards,
Jean-Marc


  • Prev by Date: Re: Sort with -Infinity fails
  • Next by Date: RE: change filename automatically in Export Command
  • Previous by thread: Re: Sort with -Infinity fails
  • Next by thread: Re: Sort with -Infinity fails