有人可以帮我理解下面的编译错误消息吗?我已经看了一段时间了,我不明白这是怎么回事。
def makeOrderedLeafList(freqs: List[(Char, Int)]): List[Leaf] = {
val buff = ListBuffer[Leaf]();
for(u<-freqs) {
val v = new Leaf(u._1, u._2)
buff += v
}
buff.toList.sortBy(_.weight) //<= offending line
}
错误信息:
scala.math.Ordering[B] 类型的发散隐式扩展从对象排序中的方法 Tuple9 开始
编辑:类声明看起来像:
abstract class CodeTree
case class Fork(left: CodeTree, right: CodeTree, chars: List[Char], weight: Int) extends CodeTree
case class Leaf(char: Char, weight: Int) extends CodeTree