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