Less return true if a token is less than another token. The caseSensitive parameter is used when the tokens are Strings. The order when comparing two different type is: Null < False < Number < String < True < JSON
(token Result, caseSensitive bool)
| 2315 | // |
| 2316 | // Null < False < Number < String < True < JSON |
| 2317 | func (t Result) Less(token Result, caseSensitive bool) bool { |
| 2318 | if t.Type < token.Type { |
| 2319 | return true |
| 2320 | } |
| 2321 | if t.Type > token.Type { |
| 2322 | return false |
| 2323 | } |
| 2324 | if t.Type == String { |
| 2325 | if caseSensitive { |
| 2326 | return t.Str < token.Str |
| 2327 | } |
| 2328 | return stringLessInsensitive(t.Str, token.Str) |
| 2329 | } |
| 2330 | if t.Type == Number { |
| 2331 | return t.Num < token.Num |
| 2332 | } |
| 2333 | return t.Raw < token.Raw |
| 2334 | } |
| 2335 | |
| 2336 | func stringLessInsensitive(a, b string) bool { |
| 2337 | for i := 0; i < len(a) && i < len(b); i++ { |