aboutsummaryrefslogtreecommitdiffstats
path: root/modules/base/natural_sort.go
blob: 0f90ec70cef44f3ea248c9b9c8a9cb259a90d598 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Copyright 2017 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package base

import (
	"golang.org/x/text/collate"
	"golang.org/x/text/language"
)

// NaturalSortLess compares two strings so that they could be sorted in natural order
func NaturalSortLess(s1, s2 string) bool {
	c := collate.New(language.English, collate.Numeric)
	return c.CompareString(s1, s2) < 0
}