I need to call usort from a class function, and I'm puzzled about how to define the comparison function.

I've tried to define the comparison function in the same class, but I can't get usort to call it. I found one hint that it will work if I make the comparison function static, but I tried that, and it didn't work for me.

If I define the comparison function outside the class, it won't have access to object properties that it needs to operate.

The only solution I can think of is to define the comparison function outside the class and put the object properties it needs in globals. Is there a cleaner way to do this?