aboutsummaryrefslogtreecommitdiff
path: root/internal/gallery/sort.go
diff options
context:
space:
mode:
authorSaiyed Shizain <saiyedshizain@gmail.com>2026-07-13 12:53:53 +0530
committerGitHub <noreply@github.com>2026-07-13 12:53:53 +0530
commited70370d9f58d39c3b31f5506e449aeb5d562a77 (patch)
tree58563adfc17bfba97b80e480d356219f63d6700c /internal/gallery/sort.go
parent1a3e963e88a76e3bf9bdab74b251331a7edfe5cb (diff)
parentf2ec755fa94c61f18873b3b9feab43eb234d2d82 (diff)
downloadgalleryd-ed70370d9f58d39c3b31f5506e449aeb5d562a77.tar.xz
galleryd-ed70370d9f58d39c3b31f5506e449aeb5d562a77.zip
Merge pull request #4 from RanXom/feat/gallery
Feat/gallery: implement gallery domain model
Diffstat (limited to 'internal/gallery/sort.go')
-rw-r--r--internal/gallery/sort.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/gallery/sort.go b/internal/gallery/sort.go
new file mode 100644
index 0000000..6c97ee3
--- /dev/null
+++ b/internal/gallery/sort.go
@@ -0,0 +1,17 @@
+package gallery
+
+import "sort"
+
+// sortPhotos orders photos by date taken (newest first).
+//
+// Photos with identical timestamps are ordered by relative path to
+// provide deterministic output.
+func sortPhotos(photos []Photo) {
+ sort.SliceStable(photos, func(i, j int) bool {
+ if !photos[i].DateTaken.Equal(photos[j].DateTaken) {
+ return photos[i].DateTaken.After(photos[j].DateTaken)
+ }
+
+ return photos[i].RelativePath < photos[j].RelativePath
+ })
+}