Using usort in php with a class private function

Make your sort function static:

private static function merchantSort($a,$b) {
       return ...// the sort
}

And use an array for the second parameter:

$array = $this->someThingThatReturnAnArray();
usort($array, array('ClassName','merchantSort'));

Leave a Comment