Re: Sort with -Infinity fails

• To: mathgroup at smc.vnet.net
• Subject: [mg73872] Re: [mg73822] Sort with -Infinity fails
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Fri, 2 Mar 2007 06:37:27 -0500 (EST)
• Reply-to: hanlonr at cox.net

```The default ordering function used in Sort  is OrderQ

Sort[{5,-Infinity,-8}]

{-8, 5, -Infinity}

OrderedQ[%]

True

Sort[{5,-Infinity,-8},OrderedQ[{##}]&]==%%

True

OrderedQ[{-Infinity,-8,5}]

False

Use Less for the ordering function

Sort[{5,-Infinity,-8},Less]

{-Infinity, -8, 5}

Use Greater for the reverse order

Sort[{5,-Infinity,-8},Greater]

{5, -8, -Infinity}

Bob Hanlon

---- Tom Aldenberg <Tom.Aldenberg at rivm.nl> 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, -=1B\$B!g=1B(B}
>
>
> Regards,
>
> Tom Aldenberg
>
> _________________________________________________________________________=
___
>
> DISCLAIMER:  http://www.rivm.nl/disclaimer.htm

```

• Prev by Date: RE: change filename automatically in Export Command
• Next by Date: Re: change filename automatically in Export Command
• Previous by thread: Re: Sort with -Infinity fails
• Next by thread: NDSolve. Getting the final values