Re: Sorting with Infinity

• To: mathgroup at smc.vnet.net
• Subject: [mg23526] Re: [mg23513] Sorting with Infinity
• From: Carl Woll <carlw at u.washington.edu>
• Date: Tue, 16 May 2000 22:29:58 -0400 (EDT)
• References: <200005160644.CAA17488@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Jack,

Use the sorting function option of Sort:

In[1]:=
Sort[{7, -2, -Infinity, Infinity, 1}, Less]

Out[1]=
{-Infinity, -2, 1, 7, Infinity}

Carl

Jack Goldberg wrote:

> Hi group;
>
> I construct lists which may look like this
>
>         {7,-2,-Infinity,Infinity,1}
>
> When this list is sorted by using Sort, I get
>
>         {-2,1,7,-Infinity,Infinity}
>
> I would prefer, naturally,
>
>         {-Infinity,-2,1,7,Infinity}
>
> This is easy to do if one doesn't care about elegance.  Without
> spelling out the obvious details, here are a few kludges:
>
> (1) Replace Infinity by 10^15, Sort  then switch back to Infinity.
> (2) Use Append and Prepend after Sort and  deleting infinities.
> (3) RotateRight after Sort and switch signs on infinities
>
> Anyone got a "cute" solution say by using a sorting function or
> perhaps some arcane command unknown to mere mortals?
>
> Jack
>
>

```

• Prev by Date: Re: Sorting with Infinity
• Next by Date: Re: Sorting with Infinity
• Previous by thread: Sorting with Infinity
• Next by thread: Re: Sorting with Infinity