Added natural sort for scene and image titles (#943)

* Added natural sort for scene and images
* Use natural sort for movie names

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
JoeSmithStarkers
2020-11-25 20:09:07 +11:00
committed by GitHub
parent 794ea00d37
commit df37ddcc2c
14 changed files with 154 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import (
"os"
"time"
"github.com/fvbommel/sortorder"
"github.com/gobuffalo/packr/v2"
"github.com/golang-migrate/migrate/v4"
sqlite3mig "github.com/golang-migrate/migrate/v4/database/sqlite3"
@@ -225,6 +226,19 @@ func registerCustomDriver() {
}
}
// COLLATE NATURAL_CS - Case sensitive natural sort
err := conn.RegisterCollation("NATURAL_CS", func(s string, s2 string) int {
if sortorder.NaturalLess(s, s2) {
return -1
} else {
return 1
}
})
if err != nil {
return fmt.Errorf("Error registering natural sort collation: %s", err.Error())
}
return nil
},
},