Skip to content

Commit 60fea25

Browse files
author
Nils Plaschke
committed
Merge pull request Chumper#309 from timgws/fix-collection-engine
Here's hoping that this fixes the CollectionEngine!
2 parents 7a20a57 + 620e97e commit 60fea25

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/Chumper/Datatable/Engines/CollectionEngine.php

+12-7
Original file line numberDiff line numberDiff line change
@@ -243,26 +243,31 @@ private function doInternalOrder()
243243
return;
244244

245245
$column = $this->orderColumn[0];
246+
$direction = $this->orderDirection[0];
246247
$stripOrder = $this->options['stripOrder'];
247-
$self = $this;
248-
$this->workingCollection->sortBy(function($row) use ($column,$stripOrder,$self) {
249248

250-
if($self->getAliasMapping())
249+
$sortFunction = 'sortBy';
250+
if ($direction == BaseEngine::ORDER_DESC)
251+
$sortFunction = 'sortByDesc';
252+
253+
$this->workingCollection->{$sortFunction}(function($row) use ($column,$stripOrder) {
254+
255+
if($this->getAliasMapping())
251256
{
252-
$column = $self->getNameByIndex($column);
257+
$column = $this->getNameByIndex($column[0]);
258+
return $row[$column];
253259
}
254260
if($stripOrder)
255261
{
256262
return strip_tags($row[$column]);
257263
}
258264
else
259265
{
266+
if (is_array($column))
267+
return $row[$column[0]];
260268
return $row[$column];
261269
}
262270
});
263-
264-
if($this->orderDirection == BaseEngine::ORDER_DESC)
265-
$this->workingCollection = $this->workingCollection->reverse();
266271
}
267272

268273
private function compileArray($columns)

0 commit comments

Comments
 (0)