Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

RE: Strange behavior of Sort

  • To: mathgroup at
  • Subject: [mg12968] RE: [mg12941] Strange behavior of Sort
  • From: Ersek_Ted%PAX1A at
  • Date: Sun, 28 Jun 1998 02:51:56 -0400
  • Sender: owner-wri-mathgroup at

Edward Neuman  wrote:
|In Mathematica 3.0:
|li={1/Sqrt[2], 1, -Sqrt[2]};
|{1, 1/Sqrt[2], -Sqrt[2]}
|Sort doesn't work properly on this list. |

Lets look at that some more.


As you pointed out simple application of Sort will not sort them in 
increasing order.

{-2.,  -1.,  0,  1.,  2.,  -0.707107,  0.707107,  -1.41421,  1.41421}

If you want them sorted numerically you can specify an appropriate
ordering  function.
Sort[lst,  Less]//N

{-2.,  -1.41421,  -1.,  -0.707107,  0,  0.707107,  1.,  1.41421,  2.}

Now what is the default ordering function? Dave Withoff posted it once,
but I didn't understand what he was saying.

Ted Ersek

  • Prev by Date: Re: Find Max of "Concave" List
  • Next by Date: Re: Fw: greek symbols in eps files
  • Previous by thread: Re: Strange behavior of Sort
  • Next by thread: Re: Strange behavior of Sort