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 <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Jonathan Amsterdam 2020-10-29 12:25:31 -04:00
Родитель 2c6a27eca9
Коммит 5142799a31
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

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