# Extracting parts of a list subject to a condition

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.

• Don't use formatting commands like Grid to initialize lists, see bullet point 6 here. Jan 8, 2015 at 20:56
• Hi ! Please, visit the help centre and read more about proper code formatting. Thanks ! Jan 8, 2015 at 21:21
• 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! Jan 8, 2015 at 21:23
• 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? Jan 8, 2015 at 21:55
• can you provide an actual numerical example, along with the desired result? Jan 9, 2015 at 1:32

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}}}