LessIgnoreCase returns true if first is alphabetically less than second.
(first string, second string)
| 8 | |
| 9 | // LessIgnoreCase returns true if first is alphabetically less than second. |
| 10 | func LessIgnoreCase(first string, second string) bool { |
| 11 | iRunes := []rune(first) |
| 12 | jRunes := []rune(second) |
| 13 | |
| 14 | max := len(iRunes) |
| 15 | if max > len(jRunes) { |
| 16 | max = len(jRunes) |
| 17 | } |
| 18 | |
| 19 | for idx := 0; idx < max; idx++ { |
| 20 | ir := iRunes[idx] |
| 21 | jr := jRunes[idx] |
| 22 | |
| 23 | lir := unicode.ToLower(ir) |
| 24 | ljr := unicode.ToLower(jr) |
| 25 | |
| 26 | if lir == ljr { |
| 27 | continue |
| 28 | } |
| 29 | |
| 30 | return lir < ljr |
| 31 | } |
| 32 | |
| 33 | return false |
| 34 | } |
| 35 | |
| 36 | // SortAlphabeticFunc returns a `less()` comparator for sorting strings while |
| 37 | // respecting case. |
no outgoing calls
no test coverage detected