diff --git a/hugolib/index.go b/hugolib/index.go index 4150d87e3..028f64a70 100644 --- a/hugolib/index.go +++ b/hugolib/index.go @@ -32,7 +32,7 @@ func (p IndexedPages) Less(i, j int) bool { if p[i].Weight == p[j].Weight { return p[i].Page.Date.Unix() > p[j].Page.Date.Unix() } else { - return p[i].Weight > p[j].Weight + return p[i].Weight < p[j].Weight } } diff --git a/hugolib/site_test.go b/hugolib/site_test.go index e08f0d6d5..a20c6e299 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -372,8 +372,8 @@ func TestOrderedPages(t *testing.T) { t.Fatalf("Unable to build site metadata: %s", err) } - if s.Sections["sect"][0].Weight != 6 || s.Sections["sect"][3].Weight != 2 { - t.Errorf("Pages in unexpected order. First should be '%s', got '%s'", 6, s.Sections["sect"][0].Weight) + if s.Sections["sect"][0].Weight != 2 || s.Sections["sect"][3].Weight != 6 { + t.Errorf("Pages in unexpected order. First should be '%s', got '%s'", 2, s.Sections["sect"][0].Weight) } if s.Sections["sect"][1].Page.Title != "Three" || s.Sections["sect"][2].Page.Title != "Four" { @@ -437,12 +437,12 @@ func TestWeightedIndexes(t *testing.T) { t.Fatalf("Unable to build site metadata: %s", err) } - if s.Indexes["tags"]["a"][0].Page.Title != "bar" { - t.Errorf("Pages in unexpected order, 'bar' expected first, got '%v'", s.Indexes["tags"]["a"][0].Page.Title) + if s.Indexes["tags"]["a"][0].Page.Title != "foo" { + t.Errorf("Pages in unexpected order, 'foo' expected first, got '%v'", s.Indexes["tags"]["a"][0].Page.Title) } - if s.Indexes["categories"]["d"][0].Page.Title != "foo" { - t.Errorf("Pages in unexpected order, 'foo' expected first, got '%v'", s.Indexes["categories"]["d"][0].Page.Title) + if s.Indexes["categories"]["d"][0].Page.Title != "bar" { + t.Errorf("Pages in unexpected order, 'bar' expected first, got '%v'", s.Indexes["categories"]["d"][0].Page.Title) } if s.Indexes["categories"]["e"][0].Page.Title != "bza" {