mirror of https://github.com/k3s-io/k3s
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
520 B
30 lines
520 B
6 years ago
|
package cli
|
||
|
|
||
|
import "unicode"
|
||
|
|
||
|
// lexicographicLess compares strings alphabetically considering case.
|
||
|
func lexicographicLess(i, j string) bool {
|
||
|
iRunes := []rune(i)
|
||
|
jRunes := []rune(j)
|
||
|
|
||
|
lenShared := len(iRunes)
|
||
|
if lenShared > len(jRunes) {
|
||
|
lenShared = len(jRunes)
|
||
|
}
|
||
|
|
||
|
for index := 0; index < lenShared; index++ {
|
||
|
ir := iRunes[index]
|
||
|
jr := jRunes[index]
|
||
|
|
||
|
if lir, ljr := unicode.ToLower(ir), unicode.ToLower(jr); lir != ljr {
|
||
|
return lir < ljr
|
||
|
}
|
||
|
|
||
|
if ir != jr {
|
||
|
return ir < jr
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return i < j
|
||
|
}
|