Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7605 > unrolled thread

Default sort of vector is by "complexity" of expression!!?????

Started byChris Young <cy56@comcast.net>
First post2012-01-06 09:16 +0000
Last post2012-01-07 10:24 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Default sort of vector is by "complexity" of expression!!????? Chris Young <cy56@comcast.net> - 2012-01-06 09:16 +0000
    Re: Default sort of vector is by "complexity" of expression!!????? danl@wolfram.com - 2012-01-07 10:18 +0000
    Re: Default sort of vector is by "complexity" of expression!!????? "Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com> - 2012-01-07 10:24 +0000

#7605 — Default sort of vector is by "complexity" of expression!!?????

FromChris Young <cy56@comcast.net>
Date2012-01-06 09:16 +0000
SubjectDefault sort of vector is by "complexity" of expression!!?????
Message-ID<je6e4i$q73$1@smc.vnet.net>
Why on earth is that the default?? How is that possibly of any use?

In[1114]:= hexN = hex // N

Out[1114]= {{0., 0.}, {1., 0.}, {0.5, 0.866025}, {-0.5,
  0.866025}, {-1., 0.}, {-0.5, -0.866025}, {0.5, -0.866025}}

In[1115]:= {Part[#, 2], Part[#, 1], #} & /@ hexN

Out[1115]= {{0., 0., {0., 0.}}, {0., 1., {1., 0.}}, {0.866025,
  0.5, {0.5, 0.866025}}, {0.866025, -0.5, {-0.5,
   0.866025}}, {0., -1., {-1.,
   0.}}, {-0.866025, -0.5, {-0.5, -0.866025}}, {-0.866025,
  0.5, {0.5, -0.866025}}}

In[1116]:= Sort[%1115]

Out[1116]= {{-0.866025, -0.5, {-0.5, -0.866025}}, {-0.866025,
  0.5, {0.5, -0.866025}}, {0., -1., {-1., 0.}}, {0.,
  0., {0., 0.}}, {0.,
  1., {1., 0.}}, {0.866025, -0.5, {-0.5, 0.866025}}, {0.866025,
  0.5, {0.5, 0.866025}}}

[toc] | [next] | [standalone]


#7619

Fromdanl@wolfram.com
Date2012-01-07 10:18 +0000
Message-ID<je965u$itf$1@smc.vnet.net>
In reply to#7605
One has to have some default ordering. The relevant criterion in the reference page for Sort states "Sort usually orders expressions by putting shorter ones first, and then comparing parts in a depth-first manner." As best I recall, it checks length and goes to subparts in case of tie.

I see nothing particularly bad about this default ordering, I might add. In particular I do not know what badness the example provided is meant to convey.

Daniel Lichtblau
Wolfram Research

[toc] | [prev] | [next] | [standalone]


#7630

From"Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com>
Date2012-01-07 10:24 +0000
Message-ID<je96ge$j3g$1@smc.vnet.net>
In reply to#7605
I don't see a sort on complexity. I see a list of lists being sorted
based on the first element of each list and ties being broken, by
using the next list element.

Cheers -- Sjoerd


----
Check out Stackoverflow's Mathematica tag: http://stackoverflow.com/questions/tagged/mathematica
or better, help out with the new dedicated Mathematica Q&A site on
StackExchange.
It's almost in private beta, but needs just a few extra people to kick
off and participate. Go to:
http://area51.stackexchange.com/proposals/37304/mathematica?referrer=EJOMFcZOBpAIDM_
9uBjtlA2

On Jan 6, 10:16 am, Chris Young <c...@comcast.net> wrote:
> Why on earth is that the default?? How is that possibly of any use?
>
> In[1114]:= hexN = hex // N
>
> Out[1114]= {{0., 0.}, {1., 0.}, {0.5, 0.866025}, {-0.5,
>   0.866025}, {-1., 0.}, {-0.5, -0.866025}, {0.5, -0.866025}}
>
> In[1115]:= {Part[#, 2], Part[#, 1], #} & /@ hexN
>
> Out[1115]= {{0., 0., {0., 0.}}, {0., 1., {1., 0.}}, {0.866025,
>   0.5, {0.5, 0.866025}}, {0.866025, -0.5, {-0.5,
>    0.866025}}, {0., -1., {-1.,
>    0.}}, {-0.866025, -0.5, {-0.5, -0.866025}}, {-0.866025,
>   0.5, {0.5, -0.866025}}}
>
> In[1116]:= Sort[%1115]
>
> Out[1116]= {{-0.866025, -0.5, {-0.5, -0.866025}}, {-0.866025,
>   0.5, {0.5, -0.866025}}, {0., -1., {-1., 0.}}, {0.,
>   0., {0., 0.}}, {0.,
>   1., {1., 0.}}, {0.866025, -0.5, {-0.5, 0.866025}}, {0.866025,
>   0.5, {0.5, 0.866025}}}

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web