github.com/codingeasygo/util@v0.0.0-20231206062002-1ce2f004b7d9/xsort/xsort_test.go (about) 1 package xsort 2 3 import "testing" 4 5 type testobj struct { 6 Val string 7 } 8 9 func (t *testobj) Less(other interface{}) bool { 10 return t.Val < other.(*testobj).Val 11 } 12 13 func TestSort(t *testing.T) { 14 a, b := &testobj{Val: "b"}, &testobj{Val: "a"} 15 vals := []*testobj{a, b} 16 Sort(vals) 17 }