From 5592026db7bcaafc473a440071c2397988f072f9 Mon Sep 17 00:00:00 2001 From: "Ian M. Jones" Date: Tue, 18 May 2021 20:00:16 +0100 Subject: [PATCH] Fix post ordering by Weight, reversed Date and FilePath. --- dir.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dir.go b/dir.go index d903761..e3437b1 100644 --- a/dir.go +++ b/dir.go @@ -262,8 +262,17 @@ func (d *Dir) write(dstDir string, task *Task) error { func (d *Dir) sort() { sort.Slice(d.Pages, func(i, j int) bool { pi, pj := d.Pages[i], d.Pages[j] - return pi.Weight < pj.Weight || pi.Date.After(pj.Date) || - pi.FilePath < pj.FilePath + return pi.FilePath < pj.FilePath + }) + + sort.SliceStable(d.Pages, func(i, j int) bool { + pi, pj := d.Pages[i], d.Pages[j] + return pi.Date.After(pj.Date) + }) + + sort.SliceStable(d.Pages, func(i, j int) bool { + pi, pj := d.Pages[i], d.Pages[j] + return pi.Weight < pj.Weight }) for i := range d.Pages {