I have a class F which is quite large so I’ve left out the details. I have defined an ordering by implementing Ordered[F] on class F and its subclasses.
I get some strange behaviour which I believe may be because I have got the compare method wrong in one of the subclasses of F. I’m trying to pin down the error and have produced the below script.
println("pre sorting: " + orderedpre) // prints List(myob1, myob2) println(orderedpre(0)) // prints myob1 println(orderedpre(1)) // prints myob2 println(orderedpre(0) <= orderedpre(1)) // prints true println(orderedpre(0) < orderedpre(1)) // prints true println(orderedpre.sorted) // prints: List(myob2, myob1)
This is confusing since surely if the zeroth element is <= the first, then it shouldn’t get swapped by Seq.sorted?
I note Seq.sorted uses an Ordering rather than an Ordered. Could this be the problem?