Commit 60fea25 Nils Plaschke
committed
File tree 1 file changed +12
-7
lines changed
src/Chumper/Datatable/Engines
1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -243,26 +243,31 @@ private function doInternalOrder()
243
243
return ;
244
244
245
245
$ column = $ this ->orderColumn [0 ];
246
+ $ direction = $ this ->orderDirection [0 ];
246
247
$ stripOrder = $ this ->options ['stripOrder ' ];
247
- $ self = $ this ;
248
- $ this ->workingCollection ->sortBy (function ($ row ) use ($ column ,$ stripOrder ,$ self ) {
249
248
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 ())
251
256
{
252
- $ column = $ self ->getNameByIndex ($ column );
257
+ $ column = $ this ->getNameByIndex ($ column [0 ]);
258
+ return $ row [$ column ];
253
259
}
254
260
if ($ stripOrder )
255
261
{
256
262
return strip_tags ($ row [$ column ]);
257
263
}
258
264
else
259
265
{
266
+ if (is_array ($ column ))
267
+ return $ row [$ column [0 ]];
260
268
return $ row [$ column ];
261
269
}
262
270
});
263
-
264
- if ($ this ->orderDirection == BaseEngine::ORDER_DESC )
265
- $ this ->workingCollection = $ this ->workingCollection ->reverse ();
266
271
}
267
272
268
273
private function compileArray ($ columns )
You can’t perform that action at this time.
0 commit comments