How to write Highest X of all party members

I'm looking for a way to write out of all alive party members, who has the most/least hp/mp/tp and put it in a damage formula. 


I had something similar made for me in order to get a passive state but copy pasting it in the formula doesn't work.


$gameParty.members().sort(function(b1,b2){


return (b1.tp > b2.tp) ? 1 : ( (b1.tp < b2.tp) ? -1 : 0 );


}).pop() === user
Math.max.apply(null, $gameParty.members().map(function(mbr) { return mbr.tp }))


I don't have MV with me, so can't test this, but I know the Math.max.apply part is correct, as I had to do this for a plugin just recently.
Thanks, l managed to make something that work with what you gave me.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-write-highest-x-of-all-party-members.74330/