instanceList = []
class Myclass:
def __init__(self, int, str):
self.int = int
self.str = str
instanceList.append(Myclass(10, "hello"))
instanceList.append(Myclass(5, "world"))
instanceList.append(Myclass(20, "string"))
Is there a way that I can find the index of the instance with the lowest 'int' attribute in 'intanceList'?
For example, a function that could do this:
minIndex = minInt(instanceList)
print(instanceList[minIndex].int)
Where the function 'minInt' would return the index of which instance with the lowest 'int' attribute. Therefore, this code should print '5', and the 'minIndex' variable should equal 1