Where does TestObject implement the Comparable interface, esp. the Compare method?
I don't see such in that rep.
The implemented TestObject.Compare method has different signature: it requests a TestObject, not a Comparable interface, as your spec!
This is only the first error.
The second is that a slice of objects cannot be converted to a slice of interface - only by manually copying:
```
diff --git a/sort_test.go b/sort_test.go
index 0874721..c89b3b3 100644
--- a/sort_test.go
+++ b/sort_test.go
@@ -13,10 +13,10 @@ type TestObject string
type TestList []TestObject
-func (this TestObject) Compare(that TestObject) int {
+func (this TestObject) Compare(that Comparable) int {
var bi, bj byte
- var x, y, z int = 0, len(this), len(that)
+ var x, y, z int = 0, len(this), len(that.(TestObject))
var d, c int = 0, 0
if y == z {
@@ -34,7 +34,7 @@ func (this TestObject) Compare(that TestObject) int {
for ; x < c; x++ {
bi = this[x]
- bj = that[x]
+ bj = (that.(TestObject))[x]
if bi != bj {
if bi < bj {
@@ -58,7 +58,11 @@ func (this TestList) Print() {
func TestSort(t *testing.T) {
var vector TestList = TestList{TestObject("20231219192613"), TestObject("20231221074246"), TestObject("20240102214104"), TestObject("20231222063428"), TestObject("20240104112200"), TestObject("20231217190339"), TestObject("20231213155157"), TestObject("20231219065525"), TestObject("20231231120412"), TestObject("20231221152849"), TestObject("20240102073948"), TestObject("20240101083455")}
- Sort(vector)
+ objs := make([]Comparable, len(vector))
+ for i := range vector {
+ objs[i] = vector[i]
+ }
+ Sort(objs)
vector.Print()
}
```