diff --git a/server.go b/server.go
index d6f0f932..f659a9f8 100644
--- a/server.go
+++ b/server.go
@@ -79,13 +79,20 @@ func AuthorsHandler(w http.ResponseWriter, r *http.Request) {
var booksHTML bytes.Buffer
booksHTML.WriteString(`
`)
aname := ""
+ matched := []Book{}
for _, b := range books {
if b.AuthorID == aid {
aname = b.Author
- booksHTML.WriteString(bookHTML(&b, true))
+ matched = append(matched, b)
found = true
}
}
+ sort.Slice(matched, func(i, j int) bool {
+ return matched[i].Title < matched[j].Title
+ })
+ for _, b := range matched {
+ booksHTML.WriteString(bookHTML(&b, true))
+ }
booksHTML.WriteString(`
`)
if found != true {
w.WriteHeader(http.StatusNotFound)