Can I sort out a list by highest or lowest value in object properties?

If so how?? I want the AI to pursue whoever has the highest value in a certain property or random from a certain range. Where can I find info on learning that?


Chee, asked and answered again:

list = [x,y,z]
for ob in list:
    if 'property' in ob:
        highestProperty = sorted(list, key=lambda sortkey: sortkey['property'], reverse=True )

#Then highestProperty[0] becomes the highest

I don’t know how to add tabs in the code?

(4 spaces = a tab)

Or you copy&paste it from an text editor.

Instead of using the lambda function, you can use itemgetter from the operator module

Thanks, everyone.