1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

switch natural sort lib for a better one (#6862)

Switched to better natural sorting package
This commit is contained in:
Matt Hook 2022-05-02 12:37:26 +12:00 committed by GitHub
parent f7780cecb3
commit 840a3ce732
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 129 deletions

View file

@ -3,8 +3,8 @@ package endpoints
import (
"strings"
"github.com/fvbommel/sortorder"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/internal/natsort"
)
type EndpointsByName []portainer.Endpoint
@ -18,7 +18,7 @@ func (e EndpointsByName) Swap(i, j int) {
}
func (e EndpointsByName) Less(i, j int) bool {
return natsort.Compare(strings.ToLower(e[i].Name), strings.ToLower(e[j].Name))
return sortorder.NaturalLess(strings.ToLower(e[i].Name), strings.ToLower(e[j].Name))
}
type EndpointsByGroup []portainer.Endpoint
@ -39,5 +39,5 @@ func (e EndpointsByGroup) Less(i, j int) bool {
groupA := endpointGroupNames[e[i].GroupID]
groupB := endpointGroupNames[e[j].GroupID]
return natsort.Compare(strings.ToLower(groupA), strings.ToLower(groupB))
return sortorder.NaturalLess(strings.ToLower(groupA), strings.ToLower(groupB))
}