PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Define the cmp function externaly (i.e. not nested)
EDIT: Follow pytrin's suggestion, but I would have defined the cmp function as private (also I'm not sure why it should be static - non static function will work the same way).
EDIT2: Oh, I think I see now the "benefits" of a publis static function in this case
Last edited by VladSun on Thu Nov 06, 2008 1:15 pm, edited 1 time in total.
There are 10 types of people in this world, those who understand binary and those who don't
pytrin wrote:The first item in the array for the usort callback should be the class name, make sure that is indeed that (not the calling function name).
darkdss wrote:Does anyone know if usort is faster than array_multisort?
That depends on your dataset & the efficiency of your sorting algorithm. If I had to guess, I would say sorting with built-in functions like array_multisort(), would be faster.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.