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