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 {