From 0eb5f54d30e950c467d5d4473fd1fb8cbff47694 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Bj=C3=B8rn=20Erik=20Pedersen?=
 <bjorn.erik.pedersen@gmail.com>
Date: Mon, 21 Nov 2016 10:35:57 +0100
Subject: [PATCH] node to page: Fix site pages sort

Updates #2297
---
 hugolib/hugo_sites.go | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go
index 0da7efb8..843bfe82 100644
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -295,12 +295,23 @@ func (h *HugoSites) createMissingPages() error {
 	}
 
 	if len(newPages) > 0 {
+		// This resorting is unfortunate, but it also needs to be sorted
+		// when sections are created.
 		first := h.Sites[0]
+
 		first.AllPages = append(first.AllPages, newPages...)
+
+		first.AllPages.Sort()
+
+		for _, s := range h.Sites {
+			s.Pages.Sort()
+		}
+
 		for i := 1; i < len(h.Sites); i++ {
 			h.Sites[i].AllPages = first.AllPages
 		}
 	}
+
 	return nil
 }
 
-- 
2.30.2