public function sort($sortBy = self::SORT_BY_KEYS_ASC, $sortFlags = SORT_REGULAR)
    {
        /** @noinspection SpellCheckingInspection */
        $sortFunctions = [
            self::SORT_BY_KEYS_ASC    => 'ksort',
            self::SORT_BY_KEYS_DESC   => 'krsort',
            self::SORT_BY_VALUES_ASC  => 'asort',
            self::SORT_BY_VALUES_DESC => 'arsort',
        ];

        if (!isset($sortFunctions[$sortBy])) {
            throw new InvalidArgumentException("SortBy {$sortBy} not supported");
        }

        $function = $sortFunctions[$sortBy];
        $function($this->data, $sortFlags);

        return $this;
    }
public function sort($sortBy = self::SORT_BY_KEYS_ASC, $sortFlags = SORT_REGULAR)
    {
        /** @noinspection SpellCheckingInspection */
        $sortFunctions = [
            self::SORT_BY_KEYS_ASC    => 'ksort',
            self::SORT_BY_KEYS_DESC   => 'krsort',
            self::SORT_BY_VALUES_ASC  => 'asort',
            self::SORT_BY_VALUES_DESC => 'arsort',
        ];

        if (!isset($sortFunctions[$sortBy])) {
            throw new InvalidArgumentException("SortBy {$sortBy} not supported");
        }

        $function = $sortFunctions[$sortBy];
        $function($this->data, $sortFlags);

        return $this;
    }
public function sort ( $ sortBy = self :: SORT_BY_KEYS_ASC , $ sortFlags = SORT_REGULAR ) { /** @noinspection SpellCheckingInspection */ $ sortFunctions = [ self :: SORT_BY_KEYS_ASC => 'ksort' , self :: SORT_BY_KEYS_DESC => 'krsort' , self :: SORT_BY_VALUES_ASC => 'asort' , self :: SORT_BY_VALUES_DESC => 'arsort' , ] ; if ( ! isset ( $ sortFunctions [ $ sortBy ] ) ) { throw new InvalidArgumentException ( "SortBy {$sortBy} not supported" ) ; } $ function = $ sortFunctions [ $ sortBy ] ; $ function ( $ this -> data , $ sortFlags ) ; return $ this ; }
Sort collection.

@param int $sortBy    Sort by flag (see self::SORT_ constants)
@param int $sortFlags Sort flags (see PHP SORT_ constants)

@return $this
@throws InvalidArgumentException
Sort collection .