Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Sorting with Infinity

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23517] Re: Sorting with Infinity
  • From: Daniel Reeves <dreeves at eecs.umich.edu>
  • Date: Tue, 16 May 2000 22:29:50 -0400 (EDT)
  • References: <8fqrpb$h5g@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The problem is that Sort uses OrderedQ and 
OrderedQ[{-Infinity, 123}] == False

But you can use Less instead, as in
Sort[list, Less]

--    --    --    --    --    --    --    --    --    --    --    -- 
Daniel Reeves               http://ai.eecs.umich.edu/people/dreeves/

Build a man a fire, and he's warm for the
rest of the evening. Set a man on fire and
he's warm for the rest of his life.

---\/   FROM Jack Goldberg ON 00.05.16 03:02 (Today)   \/---

> 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: [TS 3227] ListInterpolation
  • Next by Date: Re: Parametric Solving Question From 14 Year Old
  • Previous by thread: RE: Sorting with Infinity
  • Next by thread: Re: Sorting with Infinity