From 636a41126b296542a3de2eb57b894813222a515c Mon Sep 17 00:00:00 2001 From: adnano Date: Wed, 12 May 2021 16:35:00 -0400 Subject: [PATCH] dir: Sort by weight, date, and filepath --- dir.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dir.go b/dir.go index 36e83b1..c39a22d 100644 --- a/dir.go +++ b/dir.go @@ -274,10 +274,12 @@ func (d *Dir) write(dstDir string, task *Task) error { return nil } -// sort sorts the directory's pages by date. +// sort sorts the directory's pages by weight, then date, then filepath. func (d *Dir) sort() { sort.Slice(d.Pages, func(i, j int) bool { - return d.Pages[i].Date.After(d.Pages[j].Date) + pi, pj := d.Pages[i], d.Pages[j] + return pi.Weight < pj.Weight || pi.Date.Before(pj.Date) || + pi.FilePath < pj.FilePath }) for i := range d.Pages {