Znupi
09-23-2007, 10:56 AM
I am creating a simple CMS.
Here's the situation: I have an array which looks like:
Array
(
[0] => Array
(
[name] => download
[size] => [dir]
[href] => ?action=browse&f=&p=download/
)
[1] => Array
(
[name] => files
[size] => [dir]
[href] => ?action=browse&f=&p=files/
)
[2] => Array
(
[name] => images
[size] => [dir]
[href] => ?action=browse&f=&p=images/
)
)
And I want to sort it by name. So I wrote this function and put it inside the main class named CMSEngine:
function cb_sort($a, $b) {
return strcasecmp($a['name'], $b['name']);
}
And then tried all of these combinations, but none worked:
usort($aDirs, CMSEngine::cb_sort);
usort($aDirs, $this->cb_sort); // Yes, this happens inside another function in the same class.
usort($aDirs, "CMSEngine::cb_sort");
usort($aDirs, "$this->cb_sort");
usort($aDirs, "\$this->cb_sort");
Is there any way to do this?
Here's the situation: I have an array which looks like:
Array
(
[0] => Array
(
[name] => download
[size] => [dir]
[href] => ?action=browse&f=&p=download/
)
[1] => Array
(
[name] => files
[size] => [dir]
[href] => ?action=browse&f=&p=files/
)
[2] => Array
(
[name] => images
[size] => [dir]
[href] => ?action=browse&f=&p=images/
)
)
And I want to sort it by name. So I wrote this function and put it inside the main class named CMSEngine:
function cb_sort($a, $b) {
return strcasecmp($a['name'], $b['name']);
}
And then tried all of these combinations, but none worked:
usort($aDirs, CMSEngine::cb_sort);
usort($aDirs, $this->cb_sort); // Yes, this happens inside another function in the same class.
usort($aDirs, "CMSEngine::cb_sort");
usort($aDirs, "$this->cb_sort");
usort($aDirs, "\$this->cb_sort");
Is there any way to do this?