I have those 2 functions and I need to build a new one that will
- first sort the array by Name
-
and then move the values with
['countValue'] = 0
to the endpublic function sortOptionsByName($a, $b) { $x = trim($a['label']); $y = trim($b['label']); if ($x == '') return 1; if ($y == '') return -1; if (is_numeric($x) && is_numeric($y)){ if ($x == $y) return 0; return ($x > $y ? 1 : -1); } else { return strcasecmp($x, $y); } } public function sortOptionsByCounts($a, $b) { if ($a['countValue'] == $b['countValue']) { return 0; } return ($a['countValue'] < $b['countValue'] ? 1 : -1); }
Something like...
public function sortOptionsByCountsAndByName($a, $b)
{
if ($a['countValue'] == 0 && $b['countValue'] == 0) {
return -2
}
else {
$this->sortOptionsByName($a, $b)
}
}