I am struggling with how to extract specific contents of the list out. I am not very good at English, so I'm not sure whether I can tell clearly.

For example, I have the following nested list:

list1= {{10,{5,2}},{11.29,{3,2}},{9.22,{3,2}},
       {13.55,{3,1}},{11,{3, 1}},{0.79,{3,1}},{17.57,{5,1}},

The maximum value is 18.993. The Max formula returns this.

   Max[list1] = 18.993

But I want Mathematica to extract the following element:


The {1,2} and {2,3} and so on... after the numbers represent positions. For example, in the case of {18.993,{2,3}} the value is 18.993 that occurs at {2,3}.

What should I do?

  • $\begingroup$ Welcome to the Mathematica Stack Exchange. Try: MaximalBy[First][list1]. If you have started learning Mathematica, then you will find that the introductory book written by the inventor is a good learning resource. There is a fast intro for math students as well as a fast intro for programmers to choose from. $\endgroup$
    – Syed
    Apr 14 at 6:28
  • $\begingroup$ Its always a good idea to look at the documentation for "Max" and scrolling down to the bottom. There is always the list of functions similar to or to be used in context with the function Max. $\endgroup$
    – Roland F
    Apr 14 at 6:40
  • $\begingroup$ Thanks for your comment! $\endgroup$
    – hare
    Apr 18 at 0:11

1 Answer 1



MaximalBy[list1, (First[#] &)]
  • 4
    $\begingroup$ FWIW, you don't need a full Function, you can just use First: MaximalBy[list1, First]. Also, since MaximalBy returns a list and the OP wanted just a single element, you could do something along the lines of First[MaximalBy[list1, (First[#] &)]]. $\endgroup$
    – lericr
    Apr 14 at 7:07
  • $\begingroup$ Thank you for your Answer $\endgroup$
    – hare
    Apr 18 at 0:11

Your Answer

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

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