Hello, I need to sort a list of objects by a attribute they contain. Lets say I have class Person with attribute age. I then want to sort them by age. My solution was to make my own function to sort them with usort().
function sortByAge($objectA, $object😎
{
if($objectA->age < $objectB->age)
return $objectA;
}
It works fine, its just that I recieve these warnings for each object:
Notice: Object of class Player could not be converted to int in \web\www\script.php on line 108
Is there a better solution, or should I just ignore the warnings? in that case how?
Thanks!