Skip to content

Commit

Permalink
Fix table ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
tfamula committed Oct 2, 2024
1 parent 1558ce8 commit 406ea2a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Services/Skill/Table/classes/trait.TableRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
namespace ILIAS\Skill\Table;

use ILIAS\Data;
use ILIAS\UI\Component\Link\Link;

/**
* Wrapper for sortation and pagination of table records
Expand Down Expand Up @@ -49,17 +50,19 @@ protected function orderRecords(array $records, Data\Order $order): array
if (is_array($a[$aspect])) {
return $a[$aspect] <=> $b[$aspect];
}
if ($a[$aspect] instanceof \ILIAS\UI\Component\Link\Link) {
if ($a[$aspect] instanceof Link) {
return $a[$aspect]->getLabel() <=> $b[$aspect]->getLabel();
}
if ($a[$aspect] instanceof \DateTimeImmutable) {
return $a[$aspect]->getTimestamp() <=> $b[$aspect]->getTimestamp();
}

return strcmp($a[$aspect], $b[$aspect]);
});

if ($direction === $order::DESC) {
$records = array_reverse($records);
}

return $records;
}

Expand Down

0 comments on commit 406ea2a

Please sign in to comment.