private function sort(IDataSource $dataSource) { if ($this->sorting === NULL) { $this->sorting = $this->defaultSorting; } if ($this->sorting === NULL) { return; } // Check column list($column) = $this->sorting; if ($column != $this->primaryKey) { $column = $this['columns'][$column]; if (!$column->isSortable()) { throw new InvalidArgumentException("Column '{$column->name}' is not sortable"); } $column->setSorting(); } $dataSource->sort($this->sorting); }