MathGroup Archive 2012

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

Search the Archive

Re: SortBy won't order irrationals

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124046] Re: SortBy won't order irrationals
  • From: Shizu <slivo.vitz at msa.hinet.net>
  • Date: Sat, 7 Jan 2012 05:18:26 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

It's normal, since Mathematica sorts by structure.

This could be a simple solution:
In[]:= Sort[ptsIrr, #1[[2]] < #2[[2]] &]
Out[]:= {{-1, 0}, {7, 0}, {Sqrt[3], 1}, {6, 1}, {Sqrt[5], 1}, {4, 1}, {1, Sqrt[2]}, {2, 2}, {0, 2}}

This sorts by structure:
In[]:= Sort[{Pi, E, 2, 3, 1, Sqrt[2]}]
Out[]:= {1, 2, 3, Sqrt[2], E, \[Pi]}

This sorts by numerical values:
In[]:= Sort[{Pi, E, 2, 3, 1, Sqrt[2]}, Less]
Out[]:= {1, Sqrt[2], 2, E, 3, \[Pi]}

With SortBy[], simply you have to N[] as you did.



  • Prev by Date: Mantaining the same form
  • Next by Date: data proccess
  • Previous by thread: Re: SortBy won't order irrationals
  • Next by thread: Re: SortBy won't order irrationals