0
$\begingroup$

I've got a list like following:

{{{x1,y1,1}, {x2,y2,1}, {x3,y3,1}, {x4,y4,1}, {x5,y5,1}}

{{x6,y6,2}, {x7,y7,2}, {x8,y8,2}, {x9,y9,2}, {x10,y10,2}}

{{x11,y11,3}, {x12,y12,3}, {x13,y13,3}, {x14,y14,3}, {x15,y15,3}}}

What I want to do:

Choose out of every row the triplet with the highest x value. Then, out of these triplets, choose the one with the lowest x value.

$\endgroup$
5
  • $\begingroup$ Don't use formatting commands like Grid to initialize lists, see bullet point 6 here. $\endgroup$
    – C. E.
    Jan 8, 2015 at 20:56
  • $\begingroup$ Hi ! Please, visit the help centre and read more about proper code formatting. Thanks ! $\endgroup$
    – Sektor
    Jan 8, 2015 at 21:21
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ Jan 8, 2015 at 21:23
  • $\begingroup$ The question is not completely clear (for a start you have triplets {x,y,z} where y is actually x...) Are you just looking for the triplet with the most negative value of z? $\endgroup$ Jan 8, 2015 at 21:55
  • $\begingroup$ can you provide an actual numerical example, along with the desired result? $\endgroup$
    – george2079
    Jan 9, 2015 at 1:32

1 Answer 1

2
$\begingroup$

I'll use a $m\times n\times3$ array of random numbers as input:

list = RandomReal[{0, 1}, {10, 10, 3}];

The following finds the maximum (by first element) of each row, and then finds the minimum (by first element) of the result:

MinimalBy[MaximalBy[#, First] & /@ list, First]

producing (for my random numbers)

{{{0.741714, 0.438475, 0.85645}}}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.