src/Bag.php
public function sortKeys($order = SORT_ASC, $flags = SORT_REGULAR)
    {
        $this->validateSortArgs($order, $flags);

        $items = $this->items;

        if ($order === SORT_ASC) {
            ksort($items, $flags);
        } else {
            krsort($items, $flags);
        }

        return $this->createFrom($items);
    }
public function sortKeys($order = SORT_ASC, $flags = SORT_REGULAR)
    {
        $this->validateSortArgs($order, $flags);

        $items = $this->items;

        if ($order === SORT_ASC) {
            ksort($items, $flags);
        } else {
            krsort($items, $flags);
        }

        return $this->createFrom($items);
    }
public function sortKeys ( $ order = SORT_ASC , $ flags = SORT_REGULAR ) { $ this -> validateSortArgs ( $ order , $ flags ) ; $ items = $ this -> items ; if ( $ order === SORT_ASC ) { ksort ( $ items , $ flags ) ; } else { krsort ( $ items , $ flags ) ; } return $ this -> createFrom ( $ items ) ; }
Returns a bag with the keys sorted.

Sorting flags:
Constant                        | Description
------------------------------- | ------------------------
`SORT_REGULAR`                  | compare values without changing types
`SORT_NUMERIC`                  | compare values numerically
`SORT_STRING`                   | compare values as strings
`SORT_STRING | SORT_FLAG_CASE`  | compare values as strings ignoring case
`SORT_LOCALE_STRING`            | compare values as strings based on the current locale
`SORT_NATURAL`                  | compare values as strings using "natural ordering"
`SORT_NATURAL | SORT_FLAG_CASE` | compare values as strings using "natural ordering" ignoring case

@param int $order `SORT_ASC` or `SORT_DESC`
@param int $flags Sorting flags to modify the behavior

@return static
Returns a bag with the keys sorted .