MCPcopy Index your code
hub / github.com/expr-lang/expr / valueSortLess

Function valueSortLess

internal/spew/common.go:295–322  ·  view source on GitHub ↗

valueSortLess returns whether the first value should sort before the second value. It is used by valueSorter.Less as part of the sort.Interface implementation.

(a, b reflect.Value)

Source from the content-addressed store, hash-verified

293// value. It is used by valueSorter.Less as part of the sort.Interface
294// implementation.
295func valueSortLess(a, b reflect.Value) bool {
296 switch a.Kind() {
297 case reflect.Bool:
298 return !a.Bool() && b.Bool()
299 case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
300 return a.Int() < b.Int()
301 case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
302 return a.Uint() < b.Uint()
303 case reflect.Float32, reflect.Float64:
304 return a.Float() < b.Float()
305 case reflect.String:
306 return a.String() < b.String()
307 case reflect.Uintptr:
308 return a.Uint() < b.Uint()
309 case reflect.Array:
310 // Compare the contents of both arrays.
311 l := a.Len()
312 for i := 0; i < l; i++ {
313 av := a.Index(i)
314 bv := b.Index(i)
315 if av.Interface() == bv.Interface() {
316 continue
317 }
318 return valueSortLess(av, bv)
319 }
320 }
321 return a.String() < b.String()
322}
323
324// Less returns whether the value at index i should sort before the
325// value at index j. It is part of the sort.Interface implementation.

Callers 1

LessMethod · 0.85

Calls 2

StringMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…