diff options
| -rw-r--r-- | public/index.php | 2 | ||||
| -rw-r--r-- | src/DTS/BookmarkRepository.php | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/public/index.php b/public/index.php index 248a3ec..aabf4d7 100644 --- a/public/index.php +++ b/public/index.php @@ -18,7 +18,7 @@ $bookmarks = new BookmarkRepository($config['path_to_repository']); $template = new Template($config['path_to_templates']); -$sort = $_GET['sort'] ?? null; +$sort = $_GET['sort'] ?? 'asc'; $tag = $_GET['tag'] ?? null; diff --git a/src/DTS/BookmarkRepository.php b/src/DTS/BookmarkRepository.php index 499db8c..85d8e52 100644 --- a/src/DTS/BookmarkRepository.php +++ b/src/DTS/BookmarkRepository.php @@ -26,8 +26,8 @@ class BookmarkRepository implements \Iterator public function sort(bool $asc = true): BookmarkRepository { usort($this->repository, function ($a, $b) use ($asc) { - return $asc ? $a->addedAt <=> $b->addedAt - : $b->addedAt <=> $a->addedAt; + return $asc ? $a->title <=> $b->title + : $b->title <=> $a->title; }); return $this; |
