function sort ($type = 'sort', $flags = SORT_REGULAR, callable $fn = null)
  {
    if (!isset (self::$SORT_TYPES[$type]))
      throw new InvalidArgumentException ("Bad sort type: $type");
    $n = self::$SORT_TYPES[$type];
    $this->all ();  // force materialization of data.
    switch ($n) {
      case 1:
        $type ($this->data);
        break;
      case 2:
        $type ($this->data, $flags);
        break;
      case 3:
        $type ($this->data, $fn);
        break;
    }
    return $this;
  }
function sort ($type = 'sort', $flags = SORT_REGULAR, callable $fn = null)
  {
    if (!isset (self::$SORT_TYPES[$type]))
      throw new InvalidArgumentException ("Bad sort type: $type");
    $n = self::$SORT_TYPES[$type];
    $this->all ();  // force materialization of data.
    switch ($n) {
      case 1:
        $type ($this->data);
        break;
      case 2:
        $type ($this->data, $flags);
        break;
      case 3:
        $type ($this->data, $fn);
        break;
    }
    return $this;
  }
function sort ( $ type = 'sort' , $ flags = SORT_REGULAR , callable $ fn = null ) { if ( ! isset ( self :: $ SORT_TYPES [ $ type ] ) ) throw new InvalidArgumentException ( "Bad sort type: $type" ) ; $ n = self :: $ SORT_TYPES [ $ type ] ; $ this -> all ( ) ; // force materialization of data. switch ( $ n ) { case 1 : $ type ( $ this -> data ) ; break ; case 2 : $ type ( $ this -> data , $ flags ) ; break ; case 3 : $ type ( $ this -> data , $ fn ) ; break ; } return $ this ; }
Sorts the data by its keys.

Note: this method materializes the data.

@param string   $type  The type of sort to perform.<br>
One of:
'asort' | 'arsort' | 'krsort' | 'ksort' | 'natcasesort' | 'natsort' | 'rsort' | 'shuffle' |
'sort' | 'uasort' | 'uksort' | 'usort'
@param int      $flags One or more of the SORT_XXX constants.
@param callable $fn    Can only be specified for sort types beginning with letter `u` (ex: `usort`).
@return $this
Sorts the data by its keys .