Bolt\Twig\Handler\ArrayHandler::orderHelper PHP Метод

orderHelper() приватный Метод

Helper function for sorting an array of \Bolt\Legacy\Content.
private orderHelper ( Content | array $a, Content | array $b ) : boolean
$a Bolt\Legacy\Content | array
$b Bolt\Legacy\Content | array
Результат boolean
    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;
            }
        }
    }