I have a nested list of {x,y,z} and I want to find out the values of x and y where z is minimum. I can write a nested For loop and do it
mya = {{0, 1, 10}, {1, 1, 20}, {0, 2, 5}, {1, 2, 15}}
For[i = 1, i <= Length[mya[[All, 3]]], i++,
If[mya[[All, 3]][[i]] == Min[mya[[All, 3]]], Print[mya[[i]]]]]
I get the desired output:
{0, 2, 5}
I know this problem is simple, but if someone can tell me a more elegant way to do it, it will be helpful as I wanna do it for a very large list.
Cases[mya, x_ /; x[[3]] == Min[mya[[All, 3]]]]
is another option $\endgroup$Min[mya[[All, 3]]]
is evaluatedLength@mya
times. It may be better to let it only evaluate once as I did. $\endgroup$