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;
  }