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