From 5142799a31010d8e7cd538734db9c2a990919ba4 Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Thu, 29 Oct 2020 12:25:31 -0400 Subject: [PATCH] internal/frontend: sort source files Display the source files in sorted order. This makes them consistent, which is nice for UX but even more important for page diffing. Change-Id: If6634d51c3ff405e78c287ce59f60621179fa4cc Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/266277 Trust: Jonathan Amsterdam Run-TryBot: Jonathan Amsterdam Reviewed-by: Julie Qiu TryBot-Result: kokoro --- internal/frontend/doc.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/frontend/doc.go b/internal/frontend/doc.go index c80a6cc0..7d5dab99 100644 --- a/internal/frontend/doc.go +++ b/internal/frontend/doc.go @@ -8,6 +8,7 @@ import ( "context" "fmt" "path" + "sort" "strings" "time" @@ -96,6 +97,7 @@ func sourceFiles(u *internal.Unit, docPkg *godoc.Package) []*File { URL: u.SourceInfo.FileURL(path.Join(internal.Suffix(u.Path, u.ModulePath), f.Name)), }) } + sort.Slice(files, func(i, j int) bool { return files[i].Name < files[j].Name }) return files }