mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
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:
@@ -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
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user