private function orderByPriority(array $elements)
    {
        // Drop keys from the elements array
        $elements = array_values($elements);
        $length = count($elements);
        for ($i = 0; $i < $length; $i++) {
            for ($j = $i; $j < $length; $j++) {
                $priorityFirst = isset($elements[$i]['priority']) ? (int) $elements[$i]['priority'] : 1;
                $prioritySecond = isset($elements[$j]['priority']) ? (int) $elements[$j]['priority'] : 1;

                if ($priorityFirst < $prioritySecond) {
                    $aux = $elements[$j];
                    $elements[$j] = $elements[$i];
                    $elements[$i] = $aux;
                }
            }
        }

        return $elements;
    }
private function orderByPriority(array $elements)
    {
        // Drop keys from the elements array
        $elements = array_values($elements);
        $length = count($elements);
        for ($i = 0; $i < $length; $i++) {
            for ($j = $i; $j < $length; $j++) {
                $priorityFirst = isset($elements[$i]['priority']) ? (int) $elements[$i]['priority'] : 1;
                $prioritySecond = isset($elements[$j]['priority']) ? (int) $elements[$j]['priority'] : 1;

                if ($priorityFirst < $prioritySecond) {
                    $aux = $elements[$j];
                    $elements[$j] = $elements[$i];
                    $elements[$i] = $aux;
                }
            }
        }

        return $elements;
    }
private function orderByPriority ( array $ elements ) { // Drop keys from the elements array $ elements = array_values ( $ elements ) ; $ length = count ( $ elements ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { for ( $ j = $ i ; $ j < $ length ; $ j ++ ) { $ priorityFirst = isset ( $ elements [ $ i ] [ 'priority' ] ) ? ( int ) $ elements [ $ i ] [ 'priority' ] : 1 ; $ prioritySecond = isset ( $ elements [ $ j ] [ 'priority' ] ) ? ( int ) $ elements [ $ j ] [ 'priority' ] : 1 ; if ( $ priorityFirst < $ prioritySecond ) { $ aux = $ elements [ $ j ] ; $ elements [ $ j ] = $ elements [ $ i ] ; $ elements [ $ i ] = $ aux ; } } } return $ elements ; }
Gets provided array and orders it by priority
@param array $elements
@return array
Gets provided array and orders it by priority