Sort the slice of categories
This commit is contained in:
parent
cb01d278b3
commit
b756f64857
@ -18,7 +18,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"fmt"
|
"sort"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/alecthomas/template"
|
"github.com/alecthomas/template"
|
||||||
@ -59,7 +59,6 @@ var bookTempl = `
|
|||||||
func MakeBook(path string, opts *settings.Settings) {
|
func MakeBook(path string, opts *settings.Settings) {
|
||||||
// Everything needs to be compiled
|
// Everything needs to be compiled
|
||||||
CompileDir(path, opts)
|
CompileDir(path, opts)
|
||||||
fmt.Println(scoreCategories(&scores))
|
|
||||||
// Compile the book template
|
// Compile the book template
|
||||||
var templ = template.Must(template.New("songBook").Parse(bookTempl))
|
var templ = template.Must(template.New("songBook").Parse(bookTempl))
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ func MakeBook(path string, opts *settings.Settings) {
|
|||||||
helpers.Check(err, "could not remove songbook latex template")
|
helpers.Check(err, "could not remove songbook latex template")
|
||||||
}
|
}
|
||||||
|
|
||||||
// scoreCategories returns a slice of all categories used
|
// scoreCategories returns a sorted slice of all categories used
|
||||||
// in the given slice of scores
|
// in the given slice of scores
|
||||||
func scoreCategories(scores *[]settings.Score) []string {
|
func scoreCategories(scores *[]settings.Score) []string {
|
||||||
catMap := make(map[string]struct{})
|
catMap := make(map[string]struct{})
|
||||||
@ -113,5 +112,6 @@ func scoreCategories(scores *[]settings.Score) []string {
|
|||||||
for cat := range catMap {
|
for cat := range catMap {
|
||||||
categories = append(categories, cat)
|
categories = append(categories, cat)
|
||||||
}
|
}
|
||||||
|
sort.Strings(categories)
|
||||||
return categories
|
return categories
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user