MCPcopy
hub / github.com/google/go-cmp / sort

Method sort

cmp/cmpopts/sort.go:63–72  ·  view source on GitHub ↗
(x interface{})

Source from the content-addressed store, hash-verified

61 return !ok1 || !ok2
62}
63func (ss sliceSorter) sort(x interface{}) interface{} {
64 src := reflect.ValueOf(x)
65 dst := reflect.MakeSlice(src.Type(), src.Len(), src.Len())
66 for i := 0; i < src.Len(); i++ {
67 dst.Index(i).Set(src.Index(i))
68 }
69 sort.SliceStable(dst.Interface(), func(i, j int) bool { return ss.less(dst, i, j) })
70 ss.checkSort(dst)
71 return dst.Interface()
72}
73func (ss sliceSorter) checkSort(v reflect.Value) {
74 start := -1 // Start of a sequence of equal elements.
75 for i := 1; i < v.Len(); i++ {

Callers

nothing calls this directly

Calls 5

lessMethod · 0.95
checkSortMethod · 0.95
TypeMethod · 0.65
LenMethod · 0.65
IndexMethod · 0.45

Tested by

no test coverage detected