private function orderHelper($a, $b)
{
$aVal = $a[$this->orderOn];
$bVal = $b[$this->orderOn];
// Check the primary sorting criterium.
if ($aVal < $bVal) {
return !$this->orderAscending;
} elseif ($aVal > $bVal) {
return $this->orderAscending;
} else {
// Primary criterium is the same. Use the secondary criterium, if it is set. Otherwise return 0.
if (empty($this->orderOnSecondary)) {
return 0;
}
$aVal = $a[$this->orderOnSecondary];
$bVal = $b[$this->orderOnSecondary];
if ($aVal < $bVal) {
return !$this->orderAscendingSecondary;
} elseif ($aVal > $bVal) {
return $this->orderAscendingSecondary;
} else {
// both criteria are the same. Whatever!
return 0;
}
}
}