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


Groups > comp.soft-sys.math.mathematica > #7604

Sorting coefficients

From Chris Young <cy56@comcast.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Sorting coefficients
Date 2012-01-06 09:15 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <je6e2k$q6b$1@smc.vnet.net> (permalink)

Show all headers | View raw


I'm trying to get my points sorted first by rows first. But I'm having
trouble figuring out how to do the kind of double sorting I need with
Sort. SortBy seems very hard to figure out and I'm not sure if it's
what I need here.

I've just got a hexagonal layout of point coordinates, with another one
on the origin, and I'm trying to sort everything from lower left to
upper right. I.e., the usual ordering of going through the bottom row
from left to right, then through the middle row from left to right, etc.

Any help appreciated.

Chris Young
cy56@comcast.net


In[1043]:= Prepend[
 Table[{Re, Im}[ E^(k (2 \[Pi])/6 I)] // Through, {k, 0, 5}], {0, 0}]

Out[1043]= {{0, 0}, {1, 0}, {1/2, Sqrt[3]/2}, {-(1/2), Sqrt[3]/
  2}, {-1, 0}, {-(1/2), -(Sqrt[3]/2)}, {1/2, -(Sqrt[3]/2)}}

In[1046]:= Sort[%1043, #1[[2]] < #2[[2]] &]

Out[1046]= {{1/2, -(Sqrt[3]/2)}, {-(1/2), -(Sqrt[3]/2)}, {-1, 0}, {1,
  0}, {0, 0}, {-(1/2), Sqrt[3]/2}, {1/2, Sqrt[3]/2}}

In[1073]:= Sort[%1046, #1[[2]] < #2[[2]] &]

Out[1073]= {{-(1/2), -(Sqrt[3]/2)}, {1/2, -(Sqrt[3]/2)}, {0, 0}, {1,
  0}, {-1, 0}, {1/2, Sqrt[3]/2}, {-(1/2), Sqrt[3]/2}}

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Sorting coefficients Chris Young <cy56@comcast.net> - 2012-01-06 09:15 +0000
  Re: Sorting coefficients "jf.alcover" <jf.alcover@gmail.com> - 2012-01-07 10:22 +0000

csiph-web