Is there a function in Mathematica that compares two lists and take from first the element with the position of largest value at second:
list1= {a,b}; list2={1,2}; out = b
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityIs there a function in Mathematica that compares two lists and take from first the element with the position of largest value at second:
list1= {a,b}; list2={1,2}; out = b
If you are looking for one built-in function does this job, I think there's no such function at the moment, but your goal can be easily achieved by
list1[[Ordering[list2, -1]]]
Just realised @Corey979 mentioned the same in comments but my method would use Pick
list1={a,b,c,d,e}
list2=RandomInteger[10,5] = {0,7,7,9,1}
Pick[list1,list2,Max[list2]]
Out[54]= {d}
Pick
comes to mind:Pick[list1, list2, Max@list2]
. $\endgroup$