Reurn indexes in lexigraphical order.

This commit is contained in:
EdwardDowling
2019-06-01 16:43:00 +01:00
parent ad5d2fcd49
commit 6d83072b91
2 changed files with 13 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ package handler
import ( import (
"fmt" "fmt"
"net/http" "net/http"
"sort"
"strings" "strings"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
@@ -36,6 +37,9 @@ func (c *Controller) GetIndexes(w http.ResponseWriter, r *http.Request) {
index.Artists = append(index.Artists, index.Artists = append(index.Artists,
makeArtistFromFolder(&folder)) makeArtistFromFolder(&folder))
} }
sort.Slice(indexes[:], func(i, j int) bool {
return indexes[i].Name < indexes[j].Name
})
sub := subsonic.NewResponse() sub := subsonic.NewResponse()
sub.Indexes = &subsonic.Indexes{ sub.Indexes = &subsonic.Indexes{
LastModified: 0, LastModified: 0,

View File

@@ -5,6 +5,15 @@
"indexes": { "indexes": {
"lastModified": 0, "lastModified": 0,
"index": [ "index": [
{
"name": "#",
"artist": [
{
"id": 5,
"name": "13th Floor Lowervators"
}
]
},
{ {
"name": "A", "name": "A",
"artist": [ "artist": [
@@ -17,15 +26,6 @@
"name": "Anika" "name": "Anika"
} }
] ]
},
{
"name": "#",
"artist": [
{
"id": 5,
"name": "13th Floor Lowervators"
}
]
} }
] ]
} }