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