public function sort($order = SORT_ASC, $flags = SORT_REGULAR, $preserveKeys = false)
    {
        $this->validateSortArgs($order, $flags);

        $items = $this->items;

        if (!$preserveKeys) {
            if ($order === SORT_ASC) {
                sort($items, $flags);
            } elseif ($order === SORT_DESC) {
                rsort($items, $flags);
            }
        } else {
            if ($order === SORT_ASC) {
                asort($items, $flags);
            } elseif ($order === SORT_DESC) {
                arsort($items, $flags);
            }
        }

        return $this->createFrom($items);
    }