123456789101112131415161718192021222324252627282930 |
- package types
- import "unicode"
- // LessRunes compares two rune values, and returns true if the first argument is lexicographicaly smaller.
- func LessRunes(iRunes, jRunes []rune) bool {
- max := len(iRunes)
- if max > len(jRunes) {
- max = len(jRunes)
- }
- for idx := 0; idx < max; idx++ {
- ir := iRunes[idx]
- jr := jRunes[idx]
- lir := unicode.ToLower(ir)
- ljr := unicode.ToLower(jr)
- if lir != ljr {
- return lir < ljr
- }
- // the lowercase runes are the same, so compare the original
- if ir != jr {
- return ir < jr
- }
- }
- return len(iRunes) < len(jRunes)
- }
|