2017-09-19 16:37:03 +08:00
|
|
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
2022-11-28 02:20:29 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
2017-09-19 16:37:03 +08:00
|
|
|
|
|
|
|
package base
|
|
|
|
|
|
|
|
import (
|
2024-03-05 23:13:35 +08:00
|
|
|
"golang.org/x/text/collate"
|
|
|
|
"golang.org/x/text/language"
|
2017-09-19 16:37:03 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// NaturalSortLess compares two strings so that they could be sorted in natural order
|
|
|
|
func NaturalSortLess(s1, s2 string) bool {
|
2024-03-05 23:13:35 +08:00
|
|
|
c := collate.New(language.English, collate.Numeric)
|
|
|
|
return c.CompareString(s1, s2) < 0
|
2017-09-19 16:37:03 +08:00
|
|
|
}
|