From eb0a593d9723d4faca14da5198db76ccf8725849 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Sat, 13 Nov 2021 08:38:13 +0000 Subject: Sort by title --- public/index.php | 2 +- 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; -- cgit v1.2.3-13-gbd6f