Find the largest variable in a group

So, this must be pretty simple but I cant seem to find an answer and searching here didn’t produce any results…

I have a group with a few objects that all have an object variable with random generated values. How can I select the object with the largest value in that group?

One way to do it could be to pick the highest value at the time you generate the number.

Have two scene variables to store the highest value and the name of the object with the highest value.

highestValue = 0; highestObjectName = "";
And then go trough each object in the group and generate the random value for each and compare each value to the value stored in the scene variable.

For each Group object Do = RandomInRange(0,100) to variable randomValue of Group If randomValue of Group > highestValue :Do = randomValue of Group to highestValue :Do = Group.ObjectName() to highestObjectName

So the idea is, you go trough each object in the group, compare the value of each to the value stored in scene variable, if the one you generated is greater than the one stored in the scene variable, assign the value to the scene variable and by the end you should know exactly which object has the highest value and what that value is.