MathGroup Archive 2001

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

Search the Archive

Sorting and Selecting in MultiLevel Lists?

Suppose I want to Sort, or Select from, a multilevel list, e.g.

        myList =  { {x1,y1},  {x2,y2},  {x3,y3}, . . . }

with a Sort or Select criterion that's some function of the xn and yn values

For example, I can sort the above list on the value of x^2 + y^2 by using

    Sort[myList, (Take[#1, 1][[1]]^2 + Take[#1, 2][[1]]^2) < 
                        (Take[#2, 1][[1]]^2 + Take[#2, 2][[1]]^2) &]

Question:  Is there an easier way to get at the "x" and "y" values associated 
with the #1 and #2 arguments in Sort, or with the # argument in Select, than the 
awkward   Take[#,m][[n]]   notation used here?

  • Prev by Date: style sheeting
  • Next by Date: Re: Solving simultaneous equations with inequalities
  • Previous by thread: style sheeting
  • Next by thread: Re: Sorting and Selecting in MultiLevel Lists?