public function orderBy($column, $direction = ICollection::ASC)
{
$collection = clone $this;
$parser = $collection->getParser();
if (is_array($column)) {
foreach ($column as $col => $direction) {
$parser->processOrderByExpression($col, $direction, $collection->queryBuilder);
}
} else {
$parser->processOrderByExpression($column, $direction, $collection->queryBuilder);
}
return $collection;
}
/** * Sort data * @param Sorting $sorting * @return static */ public function sort(Sorting $sorting) { if (is_callable($sorting->getSortCallback())) { call_user_func($sorting->getSortCallback(), $this->data_source, $sorting->getSort()); return $this; } $sort = $sorting->getSort(); if (!empty($sort)) { foreach ($sort as $column => $order) { $this->data_source = $this->data_source->orderBy($column, $order); } } else { /** * Has the statement already a order by clause? */ $order = $this->data_source->getQueryBuilder()->getClause('order'); if (ArraysHelper::testEmpty($order)) { $this->data_source = $this->data_source->orderBy($this->primary_key); } } return $this; }