1
0
Fork 0
mirror of https://git.sr.ht/~adnano/kiln synced 2024-06-01 05:26:06 +02:00

dir: Sort by weight, date, and filepath

This commit is contained in:
Adnan Maolood 2021-05-12 16:35:00 -04:00
parent 9f0f776769
commit da78298c3e

6
dir.go
View File

@ -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 {