summaryrefslogtreecommitdiffstats
path: root/hugolib/taxonomy.go
diff options
context:
space:
mode:
authorNate Finch <nate.finch@gmail.com>2014-09-09 05:59:47 -0400
committerspf13 <steve.francia@gmail.com>2014-09-09 09:22:16 -0400
commit0099b5a3cb922ac3f844b5d9d9f098cd1003b0f5 (patch)
tree29502c0f6e321a8a7d21f7470a597270f402a8b8 /hugolib/taxonomy.go
parentd9964451a570aec28116f9f0a35d54a2a42fc6ce (diff)
Change all uses of sort.Sort to sort.Stable.Using sort.Stable ensures that even if the sort keys are the same, the order of the sort will not randomly change. Using the old sort.Sort, if you had pages with no date, the lists of those pages would randomly reorder every time you regenerate the list, causing spurious changes to the output. Now they'll always get ordered in the same way.
Diffstat (limited to 'hugolib/taxonomy.go')
-rw-r--r--hugolib/taxonomy.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/hugolib/taxonomy.go b/hugolib/taxonomy.go
index 890bd550c..c03061830 100644
--- a/hugolib/taxonomy.go
+++ b/hugolib/taxonomy.go
@@ -134,7 +134,7 @@ func (by OIby) Sort(taxonomy OrderedTaxonomy) {
taxonomy: taxonomy,
by: by, // The Sort method's receiver is the function (closure) that defines the sort order.
}
- sort.Sort(ps)
+ sort.Stable(ps)
}
// Len is part of sort.Interface.
@@ -162,7 +162,7 @@ func (wp WeightedPages) Pages() Pages {
func (p WeightedPages) Len() int { return len(p) }
func (p WeightedPages) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-func (p WeightedPages) Sort() { sort.Sort(p) }
+func (p WeightedPages) Sort() { sort.Stable(p) }
func (p WeightedPages) Count() int { return len(p) }
func (p WeightedPages) Less(i, j int) bool {
if p[i].Weight == p[j].Weight {